How to access a docker container running on MacOSX from another host?

后端 未结 5 546
时光取名叫无心
时光取名叫无心 2021-02-04 15:25

I\'m trying to get started with docker and want to run the Ubiquiti video controller. I have installed Docker Toolbox and managed to get the container to run on my Yosemite host

5条回答
  •  梦毁少年i
    2021-02-04 15:43

    OK, so I found a better way to do it than trying to use a bridging network adaptor. I found it in the boot2docker docs on port forwarding.

    Just use VBoxManage modifyvm default --natpf1 "my_web,tcp,,8080,,80" or use the VirtualBox GUI to specify your port forwarding for the NAT adaptor.

    Then, remove the -p option from your docker run command and use --net=host instead. That is instead of

    docker run -d -p 8080:80 --name=web nginx
    

    use

    docker run -d --net=host --name=web nginx
    

    And voila! Your web server is available at localhost:8080 on your host or YOURHOSTIP:8080 elsewhere on your LAN.

    Note that using --net=host may mess up communication between containers on the VM, but since this is the only container I plan to run, it works great for me.

提交回复
热议问题