我已经用这样的 docker 配置器定义了一个 terraform 配方:
provider "docker" {
host = "tcp://127.0.0.1:2375/"
}
# Create the network
resource "docker_network" "private_network" {
name = "${var.customer_name}_network"
}
resource "docker_container" "goagent" {
image = "${docker_image.goagent.latest}"
name = "${var.customer_name}_goagent"
command = [ "/bin/sh", "-c", "/usr/bin/supervisord" ]
network_mode = "bridge"
networks = [ "${docker_network.private_network.name}" ]
hostname = "${var.customer_name}_goagent"
}
resource "docker_image" "goagent" {
name = "local/goagent"
}
我希望容器将仅连接到动态创建的网络(使用变量 customer_name)。但我看到的是容器也连接到默认的桥接网络(172.17.0.0/16),所以它连接到两个网络。
有没有办法在 terraform 中配置容器,使其仅连接到我在网络列表中指定的网络?