terraform-provider-docker/docs/resources/network.md
2022-12-22 14:36:24 +01:00

3 KiB

page_title subcategory description
Resource docker_network - terraform-provider-docker docker_network provides a docker network resource.

Resource (docker_network)

docker_network provides a docker network resource.

Example Usage

resource "docker_network" "private_network" {
  name = "my_network"
}

Schema

Required

  • name (String) The name of the Docker network.

Optional

  • attachable (Boolean) Enable manual container attachment to the network.
  • check_duplicate (Boolean) Requests daemon to check for networks with same name.
  • driver (String) The driver of the Docker network. Possible values are bridge, host, overlay, macvlan. See network docs for more details.
  • ingress (Boolean) Create swarm routing-mesh network. Defaults to false.
  • internal (Boolean) Whether the network is internal.
  • ipam_config (Block Set) The IPAM configuration options (see below for nested schema)
  • ipam_driver (String) Driver used by the custom IP scheme of the network. Defaults to default
  • ipam_options (Map of String) Provide explicit options to the IPAM driver. Valid options vary with ipam_driver and refer to that driver's documentation for more details.
  • ipv6 (Boolean) Enable IPv6 networking. Defaults to false.
  • labels (Block Set) User-defined key/value metadata (see below for nested schema)
  • options (Map of String) Only available with bridge networks. See bridge options docs for more details.

Read-Only

  • id (String) The ID of this resource.
  • scope (String) Scope of the network. One of swarm, global, or local.

Nested Schema for ipam_config

Optional:

  • aux_address (Map of String) Auxiliary IPv4 or IPv6 addresses used by Network driver
  • gateway (String) The IP address of the gateway
  • ip_range (String) The ip range in CIDR form
  • subnet (String) The subnet in CIDR form

Nested Schema for labels

Required:

  • label (String) Name of the label
  • value (String) Value of the label

Import

Import is supported using the following syntax by providing the id:

#!/bin/bash
terraform import docker_network.foo id

Example

Assuming you created a network as follows

#!/bin/bash
docker network create foo
# prints the long ID
87b57a9b91ecab2db2a6dbf38df74c67d7c7108cbe479d6576574ec2cd8c2d73

you provide the definition for the resource as follows

resource "docker_network" "foo" {
  name = "foo"
}

then the import command is as follows

#!/bin/bash
terraform import docker_network.foo 87b57a9b91ecab2db2a6dbf38df74c67d7c7108cbe479d6576574ec2cd8c2d73