How to Disable Auto-Start for Docker Containers
How to Disable Auto-Start for Docker Containers
Docker containers are an essential part of modern development workflows, but sometimes, an automatically starting container can cause unnecessary overhead when you boot your machine. If you want to stop a Docker container from starting automatically, follow these simple steps:
1. Check Running Containers
First, list all containers to identify the one you want to modify:
1
docker ps -a
2. Inspect the Restart Policy
Check the current restart policy for your container:
1
docker inspect -f '{{.HostConfig.RestartPolicy.Name}}' <container_name_or_id>
3. Update the Restart Policy
Disable auto-start by updating the restart policy to no
:
1
docker update --restart=no <container_name_or_id>
4. Confirm Changes
Verify the updated restart policy:
1
docker inspect -f '{{.HostConfig.RestartPolicy.Name}}' <container_name_or_id>
5. Reboot and Test
Restart your computer and confirm that the container no longer starts automatically:
1
docker ps
Re-Enabling Auto-Start (Optional)
If you ever need the container to auto-start again, you can use:
1
docker update --restart=always <container_name_or_id>
With these steps, you have full control over which containers start automatically on your machine. Happy coding! ⚡️
This post is licensed under CC BY 4.0 by the author.