diff --git a/CHANGELOG.md b/CHANGELOG.md index 7862394cb..955b403c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ BUG FIXES: `docker stop`. [GH-3798] - providers/docker: Better error messaging when SSH is not ready direct to container. [GH-3763] + - providers/docker: Don't port map SSH port if container doesn't + support SSH. [GH-3857] - providers/virtualbox: On Windows, check `VBOX_MSI_INSTALL_PATH` for VBoxManage path as well. [GH-3852] - provisioners/puppet: Fix setting facter vars with Windows diff --git a/plugins/providers/docker/action/create.rb b/plugins/providers/docker/action/create.rb index c65ebdf18..b7eda1f65 100644 --- a/plugins/providers/docker/action/create.rb +++ b/plugins/providers/docker/action/create.rb @@ -105,19 +105,22 @@ module VagrantPlugins image: image, links: links, name: container_name, - ports: forwarded_ports, + ports: forwarded_ports(@provider_config.has_ssh), privileged: @provider_config.privileged, pty: false, volumes: @provider_config.volumes, } end - def forwarded_ports + def forwarded_ports(include_ssh=false) mappings = {} @machine.config.vm.networks.each do |type, options| - if type == :forwarded_port - mappings[options[:host]] = options - end + next if type != :forwarded_port + + # Don't include SSH if we've explicitly asked not to + next if options[:id] == "ssh" && !include_ssh + + mappings[options[:host]] = options end mappings.values.map do |fp|