0

I installed Docker Desktop for Windows in my Windows 10 computer, and created a hyper-v virtual machine named MobyLinuxVM. I deployed a mongodb to a new container, and mapped the port to MobyLinuxVM 27017 port. The MobyLinuxVM virtual machine ip is 10.0.75.2, and the host win10 machine ip is 192.168.1.10. The MobyLinuxVM use a internal network type hyper-v virtual switch named DockerNAT, it is the default switch for the MobyLinuxVM.

Now I can access the Mongo database from the host win10 machine. But how can I access the mongo database from other machine? I try to change the MobyLinuxVM machine network adapter to another external network type virtual switch, but I cannot get the MobyLinuxVM virtual machine IP, and I try to log in the virtual machine by SSH, but didn't konw the user name and password.

So how to access the database deployed in a windows docker container from other machine?

veben
  • 19,637
  • 14
  • 60
  • 80
YonF
  • 641
  • 5
  • 20

2 Answers2

0

Your virtual machine will get its own ip address only if you will use bridged network.Once you your hyper-v gets ip address , you will be able to access it from other machine.Issue is not with docker but network adapter of hyper-v.

Girdhar Sojitra
  • 648
  • 4
  • 14
  • Thanks for your replay, Girdhar! It seems I misunderstanded the docker for windows port map. When I run docker with parameter *-p Port1:Port2*, it seems docker for windows do something more than I understanded, the Port1 represent the port on my host win10 machine. Because some app in my host machine has use the same port, and the firewall reason, I access the container app always failed. – YonF May 09 '17 at 09:16
0

If you run a command like "docker run -p port1:port2 mongodb" then you should have an access to this service using host of machine where docker engine was run: mongodb://your_windows_machine_host:port2 This case works for me and I havn't done special settings to access mongo in container.

typik89
  • 907
  • 1
  • 10
  • 23