Home>Article>Operation and Maintenance> Will the container be deleted after restarting the docker service?

Will the container be deleted after restarting the docker service?

WBOY
WBOY Original
2022-01-17 11:05:30 6626browse

In docker, the container will not be deleted after restarting the docker service, but the container will stop running. After restarting the docker process, all docker containers running on the server will exit and will not be deleted. You can use " docker ps -a" command to view all containers.

Will the container be deleted after restarting the docker service?

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

Will the container be deleted after restarting the docker service?

In our daily work, sometimes we have to face the need to restart the docker background process Sometimes, for example, if a certain bug needs to be restarted, or if the private warehouse address is modified, docker needs to be restarted. We know that if the docker process is restarted, all docker containers running on this server will also exit, which is a big challenge to the availability of the application.

After restarting the docker service, the container will not be destroyed. It is just that the container has stopped. You can use docker ps -a to take a look.

So is there any way for us to restart the docker background process? What about one that doesn't cause the container to close? The answer is yes.

sudo vim /etc/docker/daemon.json

#添加"live-restore": true选项{ "live-restore": true}

After the modification is completed, you need to execute

sudo systemctl daemon-reload

At this time we can restart the docker process and execute

sudo systemctl restart docker

When we initialize the environment, it is best to prepare the template for docker's /etc/docker/daemon.json configuration in advance and add these configurations in advance before putting it into production. Although kubernetes can evict pods, DaemonSet cannot evict them, so this configuration is still very helpful when we have to restart the docker process.

Recommended learning: "docker video tutorial"

The above is the detailed content of Will the container be deleted after restarting the docker service?. 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