Forward Ports from boot2docker using the Vagrant Docker provider

后端 未结 2 885
粉色の甜心
粉色の甜心 2020-12-31 11:50

I\'m trying to utilize Vagrant 1.6\'s Docker provider and I seem to have run into a snag. I can successfully bring up the Docker container and guest OS, but then I can\'t ac

2条回答
  •  暖寄归人
    2020-12-31 12:11

    To forward Ports from boot2docker (as opposed to forwarding ports from a custom proxy VM that's not using boot2docker), you need to add port forwards manually through VirtualBox, or run the following script after running vagrant up:

    export PORT=3306
    export REASON=mysql
    export HOST_VM=`VBoxManage list runningvms | grep docker-host | awk '{ print $1 }' | sed 's/"//g'`
    VBoxManage controlvm $HOST_VM natpf1 "docker-$REASON-$PORT-port-forward,tcp,127.0.0.1,$PORT,,$PORT"
    

提交回复
热议问题