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:

  1. docker run -d --name some-ghost ghost
  2. gah! forgot to expose ports
  3. docker stop some-ghost
  4. docker rm some-ghost
  5. docker run -d --name some-ghost -p 8080:2368 ghost
  6. oh shit i just deleted all my posts… oh right, use a data container
  7. docker stop some-ghost
  8. docker rm some-ghost
  9. docker create -v /var/lib/ghost --name some-data busybox
  10. docker run -d --name some-ghost -p 8080:2368 --volume-from some-data ghost
  11. 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
  12. docker stop some-ghost
  13. docker rm some-ghost
  14. docker run -d --name some-ghost -p 8080:2368 --volume-from some-data --restart unless-stopped ghost
  15. 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?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hey, you tried editing /var/lib/docker/<container_id>config.v2.json and restarting the container? It’s a hacky way but for some changes does the trick

rightio - so turns out I’m doing it properly…

https://github.com/docker/docker/issues/3285

@SoreGums

If you’re familiar with python, you may want to look in to DockerMap.

It’s designed to ease quite a bit of the more repetitive actions and allows for updating container options. It does require the use of a DockerFile, though it helps there too. May be worth checking out and tinkering with if you’d like to simplify things a bit!