Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

Network

Manages a Docker Network. This can be used alongside docker_container to create virtual networks within the docker environment.

Example Usage

using Pulumi;
using Docker = Pulumi.Docker;

class MyStack : Stack
{
    public MyStack()
    {
        // Create a new docker network
        var privateNetwork = new Docker.Network("privateNetwork", new Docker.NetworkArgs
        {
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-docker/sdk/v2/go/docker"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := docker.NewNetwork(ctx, "privateNetwork", nil)
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_docker as docker

# Create a new docker network
private_network = docker.Network("privateNetwork")
import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker";

// Create a new docker network
const privateNetwork = new docker.Network("private_network", {});

Create a Network Resource

new Network(name: string, args?: NetworkArgs, opts?: CustomResourceOptions);
def Network(resource_name: str, opts: Optional[ResourceOptions] = None, attachable: Optional[bool] = None, check_duplicate: Optional[bool] = None, driver: Optional[str] = None, ingress: Optional[bool] = None, internal: Optional[bool] = None, ipam_configs: Optional[Sequence[NetworkIpamConfigArgs]] = None, ipam_driver: Optional[str] = None, ipv6: Optional[bool] = None, labels: Optional[Sequence[NetworkLabelArgs]] = None, name: Optional[str] = None, options: Optional[Mapping[str, Any]] = None)
func NewNetwork(ctx *Context, name string, args *NetworkArgs, opts ...ResourceOption) (*Network, error)
public Network(string name, NetworkArgs? args = null, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args NetworkArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args NetworkArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args NetworkArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Network Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Network resource accepts the following input properties:

Attachable bool

Enable manual container attachment to the network. Defaults to false.

CheckDuplicate bool

Requests daemon to check for networks with same name.

Driver string

Name of the network driver to use. Defaults to bridge driver.

Ingress bool

Create swarm routing-mesh network. Defaults to false.

Internal bool

Restrict external access to the network. Defaults to false.

IpamConfigs List<NetworkIpamConfigArgs>

See IPAM config below for details.

IpamDriver string

Driver used by the custom IP scheme of the network.

Ipv6 bool

Enable IPv6 networking. Defaults to false.

Labels List<NetworkLabelArgs>

See Labels below for details.

Name string

The name of the Docker network.

Options Dictionary<string, object>

Network specific options to be used by the drivers.

Attachable bool

Enable manual container attachment to the network. Defaults to false.

CheckDuplicate bool

Requests daemon to check for networks with same name.

Driver string

Name of the network driver to use. Defaults to bridge driver.

Ingress bool

Create swarm routing-mesh network. Defaults to false.

Internal bool

Restrict external access to the network. Defaults to false.

IpamConfigs []NetworkIpamConfig

See IPAM config below for details.

IpamDriver string

Driver used by the custom IP scheme of the network.

Ipv6 bool

Enable IPv6 networking. Defaults to false.

Labels []NetworkLabel

See Labels below for details.

Name string

The name of the Docker network.

Options map[string]interface{}

Network specific options to be used by the drivers.

attachable boolean

Enable manual container attachment to the network. Defaults to false.

checkDuplicate boolean

Requests daemon to check for networks with same name.

driver string

Name of the network driver to use. Defaults to bridge driver.

ingress boolean

Create swarm routing-mesh network. Defaults to false.

internal boolean

Restrict external access to the network. Defaults to false.

ipamConfigs NetworkIpamConfig[]

See IPAM config below for details.

ipamDriver string

Driver used by the custom IP scheme of the network.

ipv6 boolean

Enable IPv6 networking. Defaults to false.

labels NetworkLabel[]

See Labels below for details.

name string

The name of the Docker network.

options {[key: string]: any}

Network specific options to be used by the drivers.

attachable bool

Enable manual container attachment to the network. Defaults to false.

check_duplicate bool

Requests daemon to check for networks with same name.

driver str

Name of the network driver to use. Defaults to bridge driver.

ingress bool

Create swarm routing-mesh network. Defaults to false.

internal bool

Restrict external access to the network. Defaults to false.

ipam_configs Sequence[NetworkIpamConfigArgs]

See IPAM config below for details.

ipam_driver str

Driver used by the custom IP scheme of the network.

ipv6 bool

Enable IPv6 networking. Defaults to false.

labels Sequence[NetworkLabelArgs]

See Labels below for details.

name str

The name of the Docker network.

options Mapping[str, Any]

Network specific options to be used by the drivers.

Outputs

All input properties are implicitly available as output properties. Additionally, the Network resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Scope string
Id string
The provider-assigned unique ID for this managed resource.
Scope string
id string
The provider-assigned unique ID for this managed resource.
scope string
id str
The provider-assigned unique ID for this managed resource.
scope str

Look up an Existing Network Resource

Get an existing Network resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: NetworkState, opts?: CustomResourceOptions): Network
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, attachable: Optional[bool] = None, check_duplicate: Optional[bool] = None, driver: Optional[str] = None, ingress: Optional[bool] = None, internal: Optional[bool] = None, ipam_configs: Optional[Sequence[NetworkIpamConfigArgs]] = None, ipam_driver: Optional[str] = None, ipv6: Optional[bool] = None, labels: Optional[Sequence[NetworkLabelArgs]] = None, name: Optional[str] = None, options: Optional[Mapping[str, Any]] = None, scope: Optional[str] = None) -> Network
func GetNetwork(ctx *Context, name string, id IDInput, state *NetworkState, opts ...ResourceOption) (*Network, error)
public static Network Get(string name, Input<string> id, NetworkState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Attachable bool

Enable manual container attachment to the network. Defaults to false.

CheckDuplicate bool

Requests daemon to check for networks with same name.

Driver string

Name of the network driver to use. Defaults to bridge driver.

Ingress bool

Create swarm routing-mesh network. Defaults to false.

Internal bool

Restrict external access to the network. Defaults to false.

IpamConfigs List<NetworkIpamConfigArgs>

See IPAM config below for details.

IpamDriver string

Driver used by the custom IP scheme of the network.

Ipv6 bool

Enable IPv6 networking. Defaults to false.

Labels List<NetworkLabelArgs>

See Labels below for details.

Name string

The name of the Docker network.

Options Dictionary<string, object>

Network specific options to be used by the drivers.

Scope string
Attachable bool

Enable manual container attachment to the network. Defaults to false.

CheckDuplicate bool

Requests daemon to check for networks with same name.

Driver string

Name of the network driver to use. Defaults to bridge driver.

Ingress bool

Create swarm routing-mesh network. Defaults to false.

Internal bool

Restrict external access to the network. Defaults to false.

IpamConfigs []NetworkIpamConfig

See IPAM config below for details.

IpamDriver string

Driver used by the custom IP scheme of the network.

Ipv6 bool

Enable IPv6 networking. Defaults to false.

Labels []NetworkLabel

See Labels below for details.

Name string

The name of the Docker network.

Options map[string]interface{}

Network specific options to be used by the drivers.

Scope string
attachable boolean

Enable manual container attachment to the network. Defaults to false.

checkDuplicate boolean

Requests daemon to check for networks with same name.

driver string

Name of the network driver to use. Defaults to bridge driver.

ingress boolean

Create swarm routing-mesh network. Defaults to false.

internal boolean

Restrict external access to the network. Defaults to false.

ipamConfigs NetworkIpamConfig[]

See IPAM config below for details.

ipamDriver string

Driver used by the custom IP scheme of the network.

ipv6 boolean

Enable IPv6 networking. Defaults to false.

labels NetworkLabel[]

See Labels below for details.

name string

The name of the Docker network.

options {[key: string]: any}

Network specific options to be used by the drivers.

scope string
attachable bool

Enable manual container attachment to the network. Defaults to false.

check_duplicate bool

Requests daemon to check for networks with same name.

driver str

Name of the network driver to use. Defaults to bridge driver.

ingress bool

Create swarm routing-mesh network. Defaults to false.

internal bool

Restrict external access to the network. Defaults to false.

ipam_configs Sequence[NetworkIpamConfigArgs]

See IPAM config below for details.

ipam_driver str

Driver used by the custom IP scheme of the network.

ipv6 bool

Enable IPv6 networking. Defaults to false.

labels Sequence[NetworkLabelArgs]

See Labels below for details.

name str

The name of the Docker network.

options Mapping[str, Any]

Network specific options to be used by the drivers.

scope str

Supporting Types

NetworkIpamConfig

AuxAddress Dictionary<string, object>
Gateway string
IpRange string
Subnet string
AuxAddress map[string]interface{}
Gateway string
IpRange string
Subnet string
auxAddress {[key: string]: any}
gateway string
ipRange string
subnet string
aux_address Mapping[str, Any]
gateway str
ip_range str
subnet str

NetworkLabel

Label string

Name of the label

Value string

Value of the label

Label string

Name of the label

Value string

Value of the label

label string

Name of the label

value string

Value of the label

label str

Name of the label

value str

Value of the label

Import

Docker networks can be imported using the long id, e.g. for a network with the short id p73jelnrme5f

 $ pulumi import docker:index/network:Network foo $(docker network inspect -f {{.ID}} p73)

Package Details

Repository
https://github.com/pulumi/pulumi-docker
License
Apache-2.0
Notes
This Pulumi package is based on the docker Terraform Provider.