Follow these steps to prevent Docker containers from automatically starting after a system reboot.
To identify all containers and their current status, run:
docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.State}}\t{{.Status}}"
Stop all currently running containers with the following command:
docker stop $(docker ps -q)
For any container, check its restart policy by running:
docker inspect -f '{{.HostConfig.RestartPolicy.Name}}' <container_id_or_name>
Disable the auto-restart policy for all containers in one go:
docker ps -a -q | xargs -I {} docker update --restart=no {}
Recheck the restart policy for a container to confirm the change:
docker inspect -f '{{.HostConfig.RestartPolicy.Name}}' <container_id_or_name>
If you want to prevent Docker itself from starting at boot, disable the Docker service:
sudo systemctl disable docker
To re-enable it later:
sudo systemctl enable docker
By following these steps, Docker containers will no longer auto-start after a system reboot.