连接到 docker 主机!

连接到 docker 主机!

有人知道如何连接到 docker 主机 uri 吗?我需要设置 jenkins 在 docker 主机上执行任务?这是 docker 主机信息。这是基于 Ubuntu 的机器。

root@node1:~# netstat -tulnp | grep LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1263/sshd
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      3526/0
tcp        0      0 127.0.0.1:6011          0.0.0.0:*               LISTEN      3793/1
tcp6       0      0 :::22                   :::*                    LISTEN      1263/sshd
tcp6       0      0 ::1:6010                :::*                    LISTEN      3526/0
tcp6       0      0 ::1:6011                :::*                    LISTEN      3793/1
root@node1:~#
root@node1:~#
root@node1:~# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-12-14 06:44:46 UTC; 1 day 2h ago
     Docs: https://docs.docker.com
 Main PID: 1249 (dockerd)
    Tasks: 17
   Memory: 69.5M
      CPU: 2min 233ms
   CGroup: /system.slice/docker.service
           ├─1249 /usr/bin/dockerd -H fd://
           └─1401 containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libco

Dec 14 06:44:46 node1 dockerd[1249]: time="2017-12-14T06:44:46.551798058Z" level=info msg="Daemon has completed initialization"
Dec 14 06:44:46 node1 dockerd[1249]: time="2017-12-14T06:44:46.551973729Z" level=info msg="Docker daemon" commit=092cba3 graphdriver=aufs version=1.13.1
Dec 14 06:44:46 node1 systemd[1]: Started Docker Application Container Engine.
Dec 14 06:44:46 node1 dockerd[1249]: time="2017-12-14T06:44:46.580061946Z" level=info msg="API listen on /var/run/docker.sock"
Dec 15 06:41:09 node1 dockerd[1249]: time="2017-12-15T06:41:09.897610342Z" level=warning msg="failed to retrieve runc version: unknown output format: runc version sp
Dec 15 06:41:09 node1 dockerd[1249]: time="2017-12-15T06:41:09.900105358Z" level=warning msg="failed to retrieve docker-init version: unknown output format: tini ver
Dec 15 08:56:46 node1 dockerd[1249]: time="2017-12-15T08:56:46.836355744Z" level=warning msg="failed to retrieve runc version: unknown output format: runc version sp
Dec 15 08:56:46 node1 dockerd[1249]: time="2017-12-15T08:56:46.838301865Z" level=warning msg="failed to retrieve docker-init version: unknown output format: tini ver
Dec 15 09:06:19 node1 dockerd[1249]: time="2017-12-15T09:06:19.272709345Z" level=warning msg="failed to retrieve runc version: unknown output format: runc version sp
Dec 15 09:06:19 node1 dockerd[1249]: time="2017-12-15T09:06:19.274916674Z" level=warning msg="failed to retrieve docker-init version: unknown output format: tini ver

答案1

netstat缺少端口 2375 或 2376

https://docs.docker.com/engine/installation/linux/linux-postinstall/#allow-access-to-the-remote-api-through-a-firewall

编辑/lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375

然后/etc/default/docker

DOCKER_OPTS="-H tcp://0.0.0.0:2375"

并重新启动。

来源:https://forums.docker.com/t/cannot-connect-to-the-docker-daemon-is-the-docker-daemon-running-on-this-host/8925/17

相关内容