forked from hashicorp/vagrant
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes hashicorp#9067: Ensure new containers don't grab existing bound…
… ports Prior to this commit, if a created but exited container bound a port, and a new container grabed that same port (say for an ssh port forward), when the initial container came back up it would fail because the port also got bound to the second container. This commit fixes that behavior by first looking at what containers are already bound prior to creating a container.
- Loading branch information
Showing
7 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
plugins/providers/docker/action/prepare_forwarded_port_collision_params.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module VagrantPlugins | ||
module DockerProvider | ||
module Action | ||
class PrepareForwardedPortCollisionParams | ||
def initialize(app, env) | ||
@app = app | ||
end | ||
|
||
def call(env) | ||
machine = env[:machine] | ||
|
||
# Get the forwarded ports used by other containers and | ||
# consider those in use as well. | ||
other_used_ports = machine.provider.driver.read_used_ports | ||
env[:port_collision_extra_in_use] = other_used_ports | ||
|
||
# Build the remap for any existing collision detections | ||
remap = {} | ||
env[:port_collision_remap] = remap | ||
|
||
# Note: This might not be required yet (as it is with the virtualbox provider) | ||
# so for now we leave the remap hash empty. | ||
|
||
@app.call(env) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters