This repository has been archived by the owner on Dec 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
docker_container's ip_address is empty when using network_mode #9
Comments
👍 Just ran into this myself. Once I specified Network_mode and gave a custom network name, docker inspect's IP Address was blank, but the actual container IP address is returned properly with the command: |
which version of the |
I can confirm that the problem is present with network_mode=host, Terraform v0.11.8 + provider.docker v1.0.3 |
Merged
To implement this feature I used the baseline from #50 and even enhanced it with a new output. Now the IP Addresses can be accessed as follows: provider "docker" {
version = "1.1.0"
host = "unix:///var/run/docker.sock"
}
resource "docker_network" "network" {
name = "demo"
check_duplicate = "true"
}
resource "docker_network" "network_2" {
name = "demo-2"
check_duplicate = "true"
}
resource "docker_image" "image" {
name = "gliderlabs/alpine:latest"
keep_locally = true
}
resource "docker_container" "container" {
name = "demo-container"
image = "${docker_image.image.name}"
network_mode = "bridge"
networks = ["demo", "demo-2"]
command = ["sleep", "356d"]
}
output "network_data" {
value = "${docker_container.container.network_data}"
}
// foreach will come
// https://www.hashicorp.com/blog/hashicorp-terraform-0-12-preview-for-and-for-each
output "ip_addresses" {
value = "${list(
lookup(docker_container.container.network_data[0], "ip_address"),
lookup(docker_container.container.network_data[1], "ip_address")
)}"
} which will output you the following format
|
This was referenced Oct 19, 2018
# for free
to subscribe to this conversation on GitHub.
Already have an account?
#.
This issue was originally opened by @rkr-kununu as hashicorp/terraform#8972. It was migrated here as part of the provider split. The original body of the issue is below.
Terraform Version
Terraform v0.7.4
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
I expected that 'ip_address' would be set to ip_address of the docker container.
Actual Behavior
The 'ip_address' was not set.
Important Factoids
I did some poking around the code. It appears that the problem is two-fold.
The text was updated successfully, but these errors were encountered: