Connect to remote docker host

£可爱£侵袭症+ 提交于 2020-02-22 05:44:12

问题


I have following scenario.

  1. Two Machine ( Physical Machine)
  2. One is Windows 10 With Docker On Windows Installer and same way ubuntu 18.04 with docker-ce installed.
  3. I can run command on individual and that is fine.
  4. I want to connect Ubuntu Docker Host from Docker on Windows machine. So Docker CLI on Windows Point to deamon at Ubuntu Host.

回答1:


You will need to enable docker remote API on Ubuntu Docker Host by adding below settings in daemon.json or your startup script

[root@localhost ~]# cat /etc/docker/daemon.json
{
  "hosts": [ "unix:///var/run/docker.sock", "tcp://0.0.0.0:2376" ]
}

Once you restart docker you can connect to docker host locally by socket file and remotely by listening port (2376). Verify the listening port of docker on Ubuntu

[root@localhost ~]# netstat -ntlp | grep 2376
tcp6       0      0 :::2376                 :::*                    LISTEN      1169/dockerd

Now you can connect to this docker from Windows machine by setting the DOCKER_HOST env variable in Windows like this

PS C:\Users\YellowDog> set DOCKER_HOST=tcp://<Ubuntu-Docker_Host-IP>:2376
PS C:\Users\YellowDog> docker ps

It will list docker containers running on Ubuntu Docker Host



来源:https://stackoverflow.com/questions/52885910/connect-to-remote-docker-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!