我的問題是我可以使用docker例如 Portainer 但是當我docker在機器上運行sudodocker時無法連接到守護行程并告訴我它:
所有命令都是用root完成的。
docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
碼頭服務:
systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/docker.service.d
└─options.conf
Active: active (running) since Fri 2021-10-22 19:02:54 UTC; 4 days ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 182765 (dockerd)
Tasks: 175
Memory: 93.1M
CGroup: /system.slice/docker.service
├─182765 /usr/bin/dockerd -H unix:// --containerd=/run/containerd/containerd.sock
├─182942 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 49153 -container-ip 172.17.0.2 -container-port 27017
├─182949 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 49153 -container-ip 172.17.0.2 -container-port 27017
├─182962 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8081 -container-ip 172.18.0.2 -container-port 8080
├─182970 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8081 -container-ip 172.18.0.2 -container-port 8080
├─182984 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 6881 -container-ip 172.18.0.2 -container-port 6881
├─182990 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 6881 -container-ip 172.18.0.2 -container-port 6881
├─183004 /usr/bin/docker-proxy -proto udp -host-ip 0.0.0.0 -host-port 6881 -container-ip 172.18.0.2 -container-port 6881
├─183010 /usr/bin/docker-proxy -proto udp -host-ip :: -host-port 6881 -container-ip 172.18.0.2 -container-port 6881
├─183034 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 49154 -container-ip 172.17.0.3 -container-port 3306
├─183041 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 49154 -container-ip 172.17.0.3 -container-port 3306
├─183148 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 49155 -container-ip 172.17.0.4 -container-port 6379
├─183154 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 49155 -container-ip 172.17.0.4 -container-port 6379
├─183332 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9443 -container-ip 172.17.0.5 -container-port 9443
├─183339 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9443 -container-ip 172.17.0.5 -container-port 9443
├─183353 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9000 -container-ip 172.17.0.5 -container-port 9000
├─183360 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9000 -container-ip 172.17.0.5 -container-port 9000
├─183372 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8000 -container-ip 172.17.0.5 -container-port 8000
├─183378 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8000 -container-ip 172.17.0.5 -container-port 8000
├─186468 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.17.0.6 -container-port 80
└─186474 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8080 -container-ip 172.17.0.6 -container-port 80
Oct 27 09:31:30 falcon dockerd[182765]: time="2021-10-27T09:31:30.218332206Z" level=debug msg="Calling GET /containers/69047b41bedea4794803730ff0fa13a65e546519f9>
Oct 27 09:31:30 falcon dockerd[182765]: time="2021-10-27T09:31:30.219026938Z" level=debug msg="Calling GET /images/json?all=0"
Oct 27 09:32:58 falcon dockerd[182765]: time="2021-10-27T09:32:58.654321683Z" level=debug msg="Calling HEAD /_ping"
Oct 27 09:32:58 falcon dockerd[182765]: time="2021-10-27T09:32:58.656492046Z" level=debug msg="Calling GET /v1.37/info"
Oct 27 09:32:58 falcon dockerd[182765]: time="2021-10-27T09:32:58.673377621Z" level=debug msg="Calling GET /v1.37/containers/json?all=1&limit=0"
Oct 27 09:32:58 falcon dockerd[182765]: time="2021-10-27T09:32:58.680766521Z" level=debug msg="Calling GET /v1.37/images/json"
Oct 27 09:32:58 falcon dockerd[182765]: time="2021-10-27T09:32:58.701618241Z" level=debug msg="Calling GET /v1.37/volumes"
我可以像往常一樣使用portainer
碼頭工人版本:
docker -v
Docker version 20.10.7, build 20.10.7-0ubuntu1~20.04.2
更多資訊:
ls -l /var/run
lrwxrwxrwx 1 root root 4 Jul 31 2020 /var/run -> /run
docker.sock 已創建:
drwxr-xr-x 2 root root 40 Oct 25 20:31 docker.sock
rcat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
Wants=containerd.service
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target
任何人都知道為什么docker無法連接到守護程式?
uj5u.com熱心網友回復:
看起來您有一個容器配置為系結安裝/var/lib/docker.sock并且守護行程在創建套接字之前重新啟動了該容器。為了減少這種機會,最近發布的版本中進行了一些tweek 打包。否則,您可能希望掛載整個目錄而不是單個檔案。
要修復,請嘗試停止 docker,洗掉空目錄,然后重新啟動 docker 以查看套接字是否首先創建(這是一個競爭條件)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/338566.html
