Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Docker Swarm, replicas & exposing ports - I get 'port is already allocated' on apply #3526
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?