I actually ran into the same issue. Not sure if it's intended behavior or bug but setting forwarded_port
in a Vagrantfile with a Docker provider does nothing on the host boot2docker machine.
Unless I'm missing something, you have to either provide your own host machine with another Vagrantfile opening the correct ports or modify the one provided by Vagrant.
Approach 1: Provide your own host machine (based on boot2docker)
Here's the base Vagrantfile for the boot2docker host: boot2docker Vagrantfile. You need to edit a copy of this Vagrantfile and set your forwarded ports here.
Then, in your Docker app Vagrantfile, modify as follow:
config.vm.provider "docker" do |d|
# Specify here the path to the updated host Vagrantfile
d.vagrant_vagrantfile = "../boot2docker/Vagrantfile"
... # edited out for clarity
end
Make sure you point to your updated host machine. Here I set it to an upper level shared directory because if you want to share this machine between multiple Docker apps with seperate Vagrantfiles, you'll have to point to the same host Vagrantfile (otherwise it'll try to spin up new host VMs).
Approach 2: Update Vagrant's host machine
You can also update the Vagrantfile automatically used by Vagrant which is located in %VAGRANT_HOME%/data/docker-host/Vagrantfile
. Modify the file to open your ports.
Then do a vagrant global-status
to get the ID of the host machine and vagrant reload machineId
to restart the machine which will trigger the port re-open and update.
I'm not sure if there's a better or sanctionned way to do this but that's the only way I could have the ports forwarded all the way from Docker container to physical machine.