Reputation: 470
I have three .sh files that I run in order to build and run docker images. As of yesterday, I can't seem to create any new ones that will work. It's weird because even if I copy the working ones exactly it still doesn't work.
I can run the lines inside the shell script in a terminal and they will work. I don't know how or why this is not working.
Edit: I can run the files, but they spit out something like
Error response from daemon: No such container: foo-container
which is not true since I can see the container with docker ps
Example:
This is an old script that works
#! /bin/bash
docker stop cb-server
docker rm cb-server
docker rmi couchbase.server.container
docker build -t couchbase.server.container .
But if I make a new one with the exact same code, and run it, I get this:
Error response from daemon: No such container: cb-server
Error response from daemon: No such container: cb-server
Error response from daemon: invalid reference format
Upvotes: 1
Views: 132
Reputation: 11
I had exactly this problem when I was editing scripts on my server machine (running Ubuntu) from my PC (running windows). What fixed it was checking the end of line formatting. Editing .sh scripts on Windows leads to DOS line endings. Apparently docker cannot handle those (and can't even tell what the problem is).
Upvotes: 1
Reputation: 3662
The two "no such container" responses are likely caused because the container and images doesn't exist on your machine (e.g. you already stopped and removed them)
You may be able to wrap these commands with a conditional before attempting to run them.
https://stackoverflow.com/a/38576401/2892779
The invalid reference format may be this:
https://github.com/moby/moby/issues/25599
Only lower case characters are permitted for images names (I don't se anything in your posted script with that problem, but you said you had 3 so assuming possibly one of the others)
Upvotes: 0