YonF
YonF

Reputation: 651

Access application deployed in windows docker container from other machine

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?

Upvotes: 0

Views: 796

Answers (2)

typik89
typik89

Reputation: 967

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.

Upvotes: 0

Girdhar Sojitra
Girdhar Sojitra

Reputation: 678

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.

Upvotes: 0

Related Questions