Home > Article > Operation and Maintenance > How to exit the docker daemon
The Docker daemon is the core component responsible for running and managing Docker containers. However, there may be times when it is necessary to exit the Docker daemon, such as when the system is restarted after a reboot. This article will introduce how to exit the Docker daemon process.
1. How to exit the docker daemon process
When the Docker daemon process starts, you can specify the way the daemon process exits through parameters. The following are commonly used exit methods:
2. Implementation of exiting the Docker daemon process
There are two ways to exit the Docker daemon process:
Use the docker command to exit the Docker daemon. First, you need to check the process number of the Docker daemon, and then use the kill command to send a signal to exit the Docker daemon, as shown below:
# 查看Docker守护进程的进程号 $ ps aux | grep dockerd root 1139 0.0 0.2 139168 41496 ? Ssl 11:21 0:00 dockerd -H unix:///var/run/docker.sock # 发送SIGTERM信号退出Docker守护进程 $ kill -s SIGTERM 1139
When the Docker daemon starts, you can specify the exit method through parameters. If no exit method is specified, SIGTERM is used by default. You can change the exit method by modifying the startup parameters, as shown below:
$ sudo vim /usr/lib/systemd/system/docker.service
[Service] Type=notify ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/dockerd --shutdown-timeout 30 # 添加此行 KillMode=process
$ sudo systemctl daemon-reload $ sudo systemctl restart docker.service
3. Summary
The Docker daemon is one of the core components of Docker. Exit Docker The daemon process can use the docker command or modify the Docker daemon startup parameters. When exiting the Docker daemon, you need to choose an appropriate exit method to ensure data integrity.
The above is the detailed content of How to exit the docker daemon. For more information, please follow other related articles on the PHP Chinese website!