Hi all,
If I use an extensive docker run command to create a container is it OK to presume that when I restart the container after stopping that all those commands get run again?
Mat
Share and learn in the Docker community.
Hi all,
If I use an extensive docker run command to create a container is it OK to presume that when I restart the container after stopping that all those commands get run again?
Mat
When you inevitably docker rm
the container, you’ll have to remember what you typed initially. You have to delete and recreate the container to change things like the underlying image and environment variables. If you do need to routinely start and restart containers, you’ll probably find it easier long-term if “upgrade” isn’t a totally separate workflow.
If you do have a long involved docker run
command, you can put it in a shell script so that it’s repeatable, or use a tool like Docker Compose that expresses the same thing but in YAML syntax. Also, if the command you want to run in the container is long and involved, you can put it into a shell script when you build the image and have the run command (or the image CMD
) be running that shell script.
(The reference docs aren’t totally clear on this, but answering your actual question, I think both docker create
and docker stop
put the container in the same state, where its configuration and filesystem exist but there are no processes; and create
→ start
clearly runs the command line, so I’m guessing stop
→ start
re-runs the command line too.)