Question
How to adjust docker container run options?
Currently the only way that I know that works is to stop the container, then delete the container and create a new one....
This seems completely bonkers…
Surely there is a “proper” way to do the following:
- docker run -d –name some-ghost ghost
- gah! forgot to expose ports
- docker stop some-ghost
- docker rm some-ghost
- docker run -d –name some-ghost -p 8080:2368 ghost
- oh shit i just deleted all my posts… oh right, use a data container
- docker stop some-ghost
- docker rm some-ghost
- docker create -v /var/lib/ghost –name some-data busybox
- docker run -d –name some-ghost -p 8080:2368 –volume-from some-data ghost
- awesome, its up, now lets see what happens when i restart the host, hmm it didn’t start, oh i need to add a restart policy
- docker stop some-ghost
- docker rm some-ghost
- docker run -d –name some-ghost -p 8080:2368 –volume-from some-data –restart unless-stopped ghost
- profit!!
It is not obvious to me, seems like you need to know what you’re doing 100% up front before you even think about issuing a docker run or create command, if you forget an option you need to start again… Surely there is a modify options for container command or something?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
While not directly an answer to your question, I’d suggest looking into Docker Compose to solve the issues you are having (verbosity of the run command).
Compose abstracts all that verbosity away neatly in a “docker-compose.yml” file and takes the pressure off you to remember the complex tags required for the docker run command.
Using compose, when you want to spin up a/some container(s), all that you need to do is make sure that your terminal is in the same directory as the docker-compose.yml file and run
docker-compose up
and you’re good to go. Compose is also nice for directly linking containers together (among several other things).Highly recommended.