Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Swarm, replicas & exposing ports - I get 'port is already allocated' on apply #3526

Closed
tomwilkie opened this issue Oct 16, 2015 · 1 comment

Comments

@tomwilkie
Copy link
Contributor

* docker_container.frontend.1: Unable to start container: API error (500): Cannot start container 556d141acc87dcc4797c4a84d82cb35b49197db0009d20f2304f64c0b5146305: Bind for 0.0.0.0:80 failed: port is already allocated

I get this error consistently. I have a 3 host swarm cluster, and want to start 3 replicas of the frontend container, one on each host. One always fails to start.

My diagnosis is that, as Terraform is passing the HostConfig on start (and not on create), Swarm is making the placement decision before it knows about the port mapping, and is putting two of my frontends on the same machine.

I guess the fix is to pass HostConfig on create, but the comment in the code (https://github.com/hashicorp/terraform/blob/master/builtin/providers/docker/resource_docker_container_funcs.go#L35) seems to indicate you tried this and it didn't work. I've tried it and it does; perhaps this is an Docker version thing? Either way, would you be open to a PR which send the host config on create and start?

@ghost
Copy link

ghost commented Apr 11, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Apr 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants