Home  >  Article  >  Operation and Maintenance  >  Will restarting the docker service affect the container?

Will restarting the docker service affect the container?

青灯夜游
青灯夜游Original
2022-02-23 16:20:4210439browse

Restarting the docker service will have an impact on the container. After restarting the docker service, the container will stop running; because after restarting the docker service, all docker containers running on this server will exit and will not start with docker startup.

Will restarting the docker service affect the container?

The operating environment of this tutorial: linux5.9.8 system, docker-1.13.1 version, Dell G3 computer.

Restarting the docker service will affect the container.

After docker is restarted, all docker containers running on this server will also exit, that is, the containers will stop running and will not start following docker startup.

You can use docker ps -a to take a look.

So is there any way for us to restart the docker process and let the container start automatically?

There are two ways to set it:

1. The container has not been created yet, add the –restart=always parameter when running the container

docker run -id --restart=always -p 9999:9999 -v xxxx:xxxx 镜像名称:tag

2. If the container is already running, run the following command:

docker update --restart=always 容器名字或者容器ID

If you want it to take effect immediately, restart docker systemctl restart docker, otherwise wait until it restarts next time and it will automatically take effect

Others: If you want to stop automatic startup, Run the following command:

docker update --restart=no 容器名字或者容器ID

Recommended learning: "docker video tutorial"

The above is the detailed content of Will restarting the docker service affect the container?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn