问题
I have following scenario.
- Two Machine ( Physical Machine)
- One is Windows 10 With Docker On Windows Installer and same way ubuntu 18.04 with docker-ce installed.
- I can run command on individual and that is fine.
- 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