Warning: Stopping docker.service, but it can still be activated by: docker.socket

问题描述
使用docker时,
每次停止docker systemctl stop docker 命令执行完都会提示

Warning: Stopping docker.service, but it can still be activated by: docker.socket

原因
目前找到的问题原因是:

This is because in addition to the docker.service unit file, there is a docker.socket unit file… this is for socket activation. The warning means if you try to connect to the docker socket while the docker service is not running, then systemd will automatically start docker for you. You can get rid of this by removing /lib/systemd/system/docker.socket… you may also need to remove -H fd:// from the docker.service unit file.

来源:stack overflow

解释
这是因为除了docker.service单元文件,还有一个docker.socket单元文件…docker.socket这是用于套接字激活。
该警告意味着:如果你试图连接到docker socket,而docker服务没有运行,系统将自动启动docker。

解决方案一
你可以删除 /lib/systemd/system/docker.socket
从docker中 docker.service 文件 删除 fd://,即remove -H fd://

解决方案二
如果不想被访问时自动启动服务
输入命令:sudo systemctl stop docker.socket

总结
其实这是个挺人性化的设计,知道意思后,就不想采取什么干预了。
 

[root@worker containerd]# systemctl stop  docker
Warning: Stopping docker.service, but it can still be activated by:
  docker.socket
[root@worker containerd]# 
[root@worker containerd]# 
[root@worker containerd]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead) since Fri 2021-09-03 09:36:15 CST; 2s ago
     Docs: https://docs.docker.com
  Process: 57616 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)
 Main PID: 57616 (code=exited, status=0/SUCCESS)

Sep 03 09:33:05 worker dockerd[57616]: time="2021-09-03T09:33:05.403541781+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Sep 03 09:33:05 worker dockerd[57616]: time="2021-09-03T09:33:05.482903602+08:00" level=info msg="Loading containers: done."
Sep 03 09:33:05 worker dockerd[57616]: time="2021-09-03T09:33:05.617151573+08:00" level=info msg="Docker daemon" commit=363e9a8 graphdriver(s)=overlay2 version=20.10.5
Sep 03 09:33:05 worker dockerd[57616]: time="2021-09-03T09:33:05.617203482+08:00" level=info msg="Daemon has completed initialization"
Sep 03 09:33:05 worker systemd[1]: Started Docker Application Container Engine.
Sep 03 09:33:05 worker dockerd[57616]: time="2021-09-03T09:33:05.636539600+08:00" level=info msg="API listen on /var/run/docker.sock"
Sep 03 09:36:15 worker systemd[1]: Stopping Docker Application Container Engine...
Sep 03 09:36:15 worker dockerd[57616]: time="2021-09-03T09:36:15.836326098+08:00" level=info msg="Processing signal 'terminated'"
Sep 03 09:36:15 worker dockerd[57616]: time="2021-09-03T09:36:15.837020259+08:00" level=info msg="Daemon shutdown complete"
Sep 03 09:36:15 worker systemd[1]: Stopped Docker Application Container Engine.
[root@worker containerd]# 
[root@worker containerd]# 
[root@worker containerd]# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@worker containerd]# 
[root@worker containerd]# 
[root@worker containerd]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2021-09-03 09:36:23 CST; 2s ago
     Docs: https://docs.docker.com
 Main PID: 57947 (dockerd)
    Tasks: 11
   Memory: 46.1M
   CGroup: /system.slice/docker.service
           └─57947 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Sep 03 09:36:22 worker dockerd[57947]: time="2021-09-03T09:36:22.428266493+08:00" level=info msg="Firewalld: docker zone already exists, returning"
Sep 03 09:36:22 worker dockerd[57947]: time="2021-09-03T09:36:22.633268179+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Sep 03 09:36:22 worker dockerd[57947]: time="2021-09-03T09:36:22.654299269+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Sep 03 09:36:22 worker dockerd[57947]: time="2021-09-03T09:36:22.815893349+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Sep 03 09:36:23 worker dockerd[57947]: time="2021-09-03T09:36:23.053129977+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Sep 03 09:36:23 worker dockerd[57947]: time="2021-09-03T09:36:23.135259324+08:00" level=info msg="Loading containers: done."
Sep 03 09:36:23 worker dockerd[57947]: time="2021-09-03T09:36:23.237714534+08:00" level=info msg="Docker daemon" commit=363e9a8 graphdriver(s)=overlay2 version=20.10.5
Sep 03 09:36:23 worker dockerd[57947]: time="2021-09-03T09:36:23.237783966+08:00" level=info msg="Daemon has completed initialization"
Sep 03 09:36:23 worker systemd[1]: Started Docker Application Container Engine.
Sep 03 09:36:23 worker dockerd[57947]: time="2021-09-03T09:36:23.251892409+08:00" level=info msg="API listen on /var/run/docker.sock"
[root@worker containerd]# 
[root@worker containerd]# 

猜你喜欢

转载自blog.csdn.net/qq_42533216/article/details/121489855