terraform-provider-docker
terraform-provider-docker copied to clipboard
Docker service support for host networking
This issue was originally opened by @cjbdev as hashicorp/terraform#21729. It was migrated here as a result of the provider split. The original body of the issue is below.
Current Terraform Version
Terraform v0.11.14
Use-cases
There is a docker container I'm trying to deploy in a swarm with Terraform that requires host networking. The ports of the container change randomly with each deployment, so manually defining each port is not an option
Proposal
As of Docker 17.06 and higher, Docker supports host networking for services by specifying --network host when creating the service (https://docs.docker.com/network/host/). Here is my idea of what this could look like in Terraform:
resource "docker_service" "foo" {
name = "foo-service"
network = "host"
...
}
I'm currently bumping up against this issue, as I need to have a docker_service participate on the host network as well as an overlay or two.
One of the problems here is that the docker_service's network is being specified exclusively by network ID instead of name. With overlay networks, this is overcome by creating them, and then accessing those resources's IDs, but we're unable to access already-existing networks without being able to specify via name, or being able to specify a docker_network data object to introspect an existing network by name to get the ID.
Additionally, the host network is special... The host network's ID on each swarm node is different, so exclusively using an ID to refer it it is not going to work.
Thanks for the heads up. Let's tackle this issue in the upcoming version
yup - not being able to set --net=host means I'm going to have to deploy one of my containers differently.