terraform-provider-docker
terraform-provider-docker copied to clipboard
Docker container volumes get HostConfig bindings inserted even without 'host_path' param
This issue was originally opened by @hashibot as https://github.com/hashicorp/terraform-provider-docker/issues/13. It was migrated here as a result of the community provider takeover from @kreuzwerker. The original body of the issue is below.
This issue was originally opened by @cmacrae as hashicorp/terraform#14941. It was migrated here as part of the provider split. The original body of the issue is below.
Terraform Version
0.9.6
Affected Resource(s)
docker_container
Terraform Configuration Files
// Docker images
resource "docker_image" "alpine" {
name = "alpine:latest"
}
// Docker containers
resource "docker_container" "gogs_data" {
image = "${docker_image.alpine.latest}"
name = "gogs_data"
volumes = {
volume_name = "data"
container_path = "/data"
}
}
Expected Behavior
A Docker container will be provisioned exposing a volume named data, with the container path: /data, without any association of a local directory on the host system (as host_path is not specified).
Actual Behavior
When applying this configuration, part of the payload sent to the remote Docker API:
"Volumes": {
"/data": {}
},
"Entrypoint": null,
"HostConfig": {
"Binds": [
"data:/data:rw"
],
As you can see, HostConfig is added, mapping a bind like so: data:/data:rw.
Important Factoids
When using Triton as a remote Docker endpoint, this causes an issue, as host volumes are not supported, and the following is returned from their API:
* docker_container.gogs_data: Unable to create container: API error (500): host volumes are not supported (34be7a41-8fec-4c0d-904c-2d0ebf6a4b11)
I'm able to work around this using the Docker cli to express a container with a volume exposed without any hostconfiguration binding:
$ docker run -d -v /gogs_data --name gogs_data alpine:latest true
bfb113a6341ae345c125b144fed755965cf72583a43245e1b368d81c9faafd9b
References
This issue is stale because it has been open 60 days with no activity.
Remove stale label or comment or this will be closed in 7 days.
If you don't want this issue to be closed, please set the label pinned.
This issue is stale because it has been open 60 days with no activity.
Remove stale label or comment or this will be closed in 7 days.
If you don't want this issue to be closed, please set the label pinned.