Search code examples
dockervirtualboxdocker-for-mac

Accessing docker container from Docker for Mac


I have the following scenario:

  • Mac OS Catalina
  • Windows Virtual Machine running on VirtualBox
  • Docker for Mac (not docker-machine or Docker Toolbox)

I need to access a port that is exposed with docker run -p 80:80 nginx from the Windows VM and nothing seems to work. I tried NAT, bridge, socat... any hints?


Solution

  • Ah, I figured it out. I can access the docker service by using the bridge interface IP (but not using localhost). So in essence:

    • VM in VirtualBox should run in network bridged mode
    • use http://1.2.3.4 in the browser where 1.2.3.4 is your MacOS network interface IP address