How to set a pre-existing docker container to start on boot
Sometimes I forget to set the --restart=always
on docker containers that should be persistent. Fortunately for me the creators of docker anticipated my use case and provide a quick way for me to rectify the issue.
References
- docker update [docs.docker.com]
- Docker: Add a restart policy to a container that was already created [stackoverflow.com]
- docker - how do you disable auto-restart on a container? [stackoverflow.com]
- Docker – change container configuration in 4 ways [bobcares.com]
Solution
This really is just a one-line solution. I'm only making this post so I have muscle memory for where to reference the solution for this 'once-a-year' class of problem.
To set an existing container to always start:
docker update --restart=always
To set an existing container to stop starting on boot:
docker update --restart=no