中文 English

Enable Automatic Startup for Docker Services and Containers After Reboot

Published: 2021-04-06
docker reboot container

After rebooting the operating system, I found that the Docker service did not start and the containers did not start either. How do you make them start automatically after reboot?

Solve Two Problems

  1. Enable automatic restart for the Docker service
systemctl enable docker.service

  1. Enable automatic restart for Docker containers
docker ps -a

Use the following command to restart the container:

docker restart imageid

When running a Docker container, you can add the following parameter to make the container restart automatically after the Docker service restarts:

docker run --restart=always

If the container is already running, you can use:

docker update --restart=always <CONTAINER ID>

After rebooting the system:

docker ps -a

Reference

https://blog.csdn.net/wxb880114/article/details/82904765