docker.Network
Explore with Pulumi AI
docker.Network
provides a docker network resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker";
const privateNetwork = new docker.Network("private_network", {name: "my_network"});
import pulumi
import pulumi_docker as docker
private_network = docker.Network("private_network", name="my_network")
package main
import (
"github.com/pulumi/pulumi-docker/sdk/v4/go/docker"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := docker.NewNetwork(ctx, "private_network", &docker.NetworkArgs{
Name: pulumi.String("my_network"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Docker = Pulumi.Docker;
return await Deployment.RunAsync(() =>
{
var privateNetwork = new Docker.Network("private_network", new()
{
Name = "my_network",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.docker.Network;
import com.pulumi.docker.NetworkArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var privateNetwork = new Network("privateNetwork", NetworkArgs.builder()
.name("my_network")
.build());
}
}
resources:
privateNetwork:
type: docker:Network
name: private_network
properties:
name: my_network
Create Network Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Network(name: string, args?: NetworkArgs, opts?: CustomResourceOptions);
@overload
def Network(resource_name: str,
args: Optional[NetworkArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
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,
ipam_options: Optional[Mapping[str, Any]] = 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)
public Network(String name, NetworkArgs args)
public Network(String name, NetworkArgs args, CustomResourceOptions options)
type: docker:Network
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- 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.
- args NetworkArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control 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.
- name String
- The unique name of the resource.
- args NetworkArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var networkResource = new Docker.Network("networkResource", new()
{
Attachable = false,
CheckDuplicate = false,
Driver = "string",
Ingress = false,
Internal = false,
IpamConfigs = new[]
{
new Docker.Inputs.NetworkIpamConfigArgs
{
AuxAddress =
{
{ "string", "any" },
},
Gateway = "string",
IpRange = "string",
Subnet = "string",
},
},
IpamDriver = "string",
IpamOptions =
{
{ "string", "any" },
},
Ipv6 = false,
Labels = new[]
{
new Docker.Inputs.NetworkLabelArgs
{
Label = "string",
Value = "string",
},
},
Name = "string",
Options =
{
{ "string", "any" },
},
});
example, err := docker.NewNetwork(ctx, "networkResource", &docker.NetworkArgs{
Attachable: pulumi.Bool(false),
CheckDuplicate: pulumi.Bool(false),
Driver: pulumi.String("string"),
Ingress: pulumi.Bool(false),
Internal: pulumi.Bool(false),
IpamConfigs: docker.NetworkIpamConfigArray{
&docker.NetworkIpamConfigArgs{
AuxAddress: pulumi.Map{
"string": pulumi.Any("any"),
},
Gateway: pulumi.String("string"),
IpRange: pulumi.String("string"),
Subnet: pulumi.String("string"),
},
},
IpamDriver: pulumi.String("string"),
IpamOptions: pulumi.Map{
"string": pulumi.Any("any"),
},
Ipv6: pulumi.Bool(false),
Labels: docker.NetworkLabelArray{
&docker.NetworkLabelArgs{
Label: pulumi.String("string"),
Value: pulumi.String("string"),
},
},
Name: pulumi.String("string"),
Options: pulumi.Map{
"string": pulumi.Any("any"),
},
})
var networkResource = new Network("networkResource", NetworkArgs.builder()
.attachable(false)
.checkDuplicate(false)
.driver("string")
.ingress(false)
.internal(false)
.ipamConfigs(NetworkIpamConfigArgs.builder()
.auxAddress(Map.of("string", "any"))
.gateway("string")
.ipRange("string")
.subnet("string")
.build())
.ipamDriver("string")
.ipamOptions(Map.of("string", "any"))
.ipv6(false)
.labels(NetworkLabelArgs.builder()
.label("string")
.value("string")
.build())
.name("string")
.options(Map.of("string", "any"))
.build());
network_resource = docker.Network("networkResource",
attachable=False,
check_duplicate=False,
driver="string",
ingress=False,
internal=False,
ipam_configs=[docker.NetworkIpamConfigArgs(
aux_address={
"string": "any",
},
gateway="string",
ip_range="string",
subnet="string",
)],
ipam_driver="string",
ipam_options={
"string": "any",
},
ipv6=False,
labels=[docker.NetworkLabelArgs(
label="string",
value="string",
)],
name="string",
options={
"string": "any",
})
const networkResource = new docker.Network("networkResource", {
attachable: false,
checkDuplicate: false,
driver: "string",
ingress: false,
internal: false,
ipamConfigs: [{
auxAddress: {
string: "any",
},
gateway: "string",
ipRange: "string",
subnet: "string",
}],
ipamDriver: "string",
ipamOptions: {
string: "any",
},
ipv6: false,
labels: [{
label: "string",
value: "string",
}],
name: "string",
options: {
string: "any",
},
});
type: docker:Network
properties:
attachable: false
checkDuplicate: false
driver: string
ingress: false
internal: false
ipamConfigs:
- auxAddress:
string: any
gateway: string
ipRange: string
subnet: string
ipamDriver: string
ipamOptions:
string: any
ipv6: false
labels:
- label: string
value: string
name: string
options:
string: any
Network Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Network resource accepts the following input properties:
- Attachable bool
- Enable manual container attachment to the network.
- Check
Duplicate bool - 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 bool
- Create swarm routing-mesh network. Defaults to
false
. - Internal bool
- Whether the network is internal.
- Ipam
Configs List<NetworkIpam Config> - The IPAM configuration options
- Ipam
Driver string - Driver used by the custom IP scheme of the network. Defaults to
default
- Ipam
Options Dictionary<string, object> - Provide explicit options to the IPAM driver. Valid options vary with
ipam_driver
and refer to that driver's documentation for more details. - Ipv6 bool
- Enable IPv6 networking. Defaults to
false
. - Labels
List<Network
Label> - User-defined key/value metadata
- Name string
- The name of the Docker network.
- Options Dictionary<string, object>
- Only available with bridge networks. See bridge options docs for more details.
- Attachable bool
- Enable manual container attachment to the network.
- Check
Duplicate bool - 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 bool
- Create swarm routing-mesh network. Defaults to
false
. - Internal bool
- Whether the network is internal.
- Ipam
Configs []NetworkIpam Config Args - The IPAM configuration options
- Ipam
Driver string - Driver used by the custom IP scheme of the network. Defaults to
default
- Ipam
Options map[string]interface{} - Provide explicit options to the IPAM driver. Valid options vary with
ipam_driver
and refer to that driver's documentation for more details. - Ipv6 bool
- Enable IPv6 networking. Defaults to
false
. - Labels
[]Network
Label Args - User-defined key/value metadata
- Name string
- The name of the Docker network.
- Options map[string]interface{}
- Only available with bridge networks. See bridge options docs for more details.
- 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
Configs List<NetworkIpam Config> - The IPAM configuration options
- ipam
Driver String - Driver used by the custom IP scheme of the network. Defaults to
default
- ipam
Options Map<String,Object> - 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
List<Network
Label> - User-defined key/value metadata
- name String
- The name of the Docker network.
- options Map<String,Object>
- Only available with bridge networks. See bridge options docs for more details.
- 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
Configs NetworkIpam Config[] - The IPAM configuration options
- ipam
Driver string - Driver used by the custom IP scheme of the network. Defaults to
default
- ipam
Options {[key: string]: any} - 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
Network
Label[] - User-defined key/value metadata
- name string
- The name of the Docker network.
- options {[key: string]: any}
- Only available with bridge networks. See bridge options docs for more details.
- attachable bool
- Enable manual container attachment to the network.
- check_
duplicate bool - Requests daemon to check for networks with same name.
- driver str
- The driver of the Docker network. Possible values are
bridge
,host
,overlay
,macvlan
. See network docs for more details. - ingress bool
- Create swarm routing-mesh network. Defaults to
false
. - internal bool
- Whether the network is internal.
- ipam_
configs Sequence[NetworkIpam Config Args] - The IPAM configuration options
- ipam_
driver str - Driver used by the custom IP scheme of the network. Defaults to
default
- ipam_
options Mapping[str, Any] - Provide explicit options to the IPAM driver. Valid options vary with
ipam_driver
and refer to that driver's documentation for more details. - ipv6 bool
- Enable IPv6 networking. Defaults to
false
. - labels
Sequence[Network
Label Args] - User-defined key/value metadata
- name str
- The name of the Docker network.
- options Mapping[str, Any]
- Only available with bridge networks. See bridge options docs for more details.
- 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
Configs List<Property Map> - The IPAM configuration options
- ipam
Driver String - Driver used by the custom IP scheme of the network. Defaults to
default
- ipam
Options Map<Any> - 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 List<Property Map>
- User-defined key/value metadata
- name String
- The name of the Docker network.
- options Map<Any>
- Only available with bridge networks. See bridge options docs for more details.
Outputs
All input properties are implicitly available as output properties. Additionally, the Network resource produces the following output properties:
Look up 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,
ipam_options: Optional[Mapping[str, Any]] = 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)
public static Network get(String name, Output<String> id, NetworkState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- 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.
- Attachable bool
- Enable manual container attachment to the network.
- Check
Duplicate bool - 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 bool
- Create swarm routing-mesh network. Defaults to
false
. - Internal bool
- Whether the network is internal.
- Ipam
Configs List<NetworkIpam Config> - The IPAM configuration options
- Ipam
Driver string - Driver used by the custom IP scheme of the network. Defaults to
default
- Ipam
Options Dictionary<string, object> - Provide explicit options to the IPAM driver. Valid options vary with
ipam_driver
and refer to that driver's documentation for more details. - Ipv6 bool
- Enable IPv6 networking. Defaults to
false
. - Labels
List<Network
Label> - User-defined key/value metadata
- Name string
- The name of the Docker network.
- Options Dictionary<string, object>
- Only available with bridge networks. See bridge options docs for more details.
- Scope string
- Scope of the network. One of
swarm
,global
, orlocal
.
- Attachable bool
- Enable manual container attachment to the network.
- Check
Duplicate bool - 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 bool
- Create swarm routing-mesh network. Defaults to
false
. - Internal bool
- Whether the network is internal.
- Ipam
Configs []NetworkIpam Config Args - The IPAM configuration options
- Ipam
Driver string - Driver used by the custom IP scheme of the network. Defaults to
default
- Ipam
Options map[string]interface{} - Provide explicit options to the IPAM driver. Valid options vary with
ipam_driver
and refer to that driver's documentation for more details. - Ipv6 bool
- Enable IPv6 networking. Defaults to
false
. - Labels
[]Network
Label Args - User-defined key/value metadata
- Name string
- The name of the Docker network.
- Options map[string]interface{}
- Only available with bridge networks. See bridge options docs for more details.
- Scope string
- Scope of the network. One of
swarm
,global
, orlocal
.
- 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
Configs List<NetworkIpam Config> - The IPAM configuration options
- ipam
Driver String - Driver used by the custom IP scheme of the network. Defaults to
default
- ipam
Options Map<String,Object> - 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
List<Network
Label> - User-defined key/value metadata
- name String
- The name of the Docker network.
- options Map<String,Object>
- Only available with bridge networks. See bridge options docs for more details.
- scope String
- Scope of the network. One of
swarm
,global
, orlocal
.
- 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
Configs NetworkIpam Config[] - The IPAM configuration options
- ipam
Driver string - Driver used by the custom IP scheme of the network. Defaults to
default
- ipam
Options {[key: string]: any} - 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
Network
Label[] - User-defined key/value metadata
- name string
- The name of the Docker network.
- options {[key: string]: any}
- Only available with bridge networks. See bridge options docs for more details.
- scope string
- Scope of the network. One of
swarm
,global
, orlocal
.
- attachable bool
- Enable manual container attachment to the network.
- check_
duplicate bool - Requests daemon to check for networks with same name.
- driver str
- The driver of the Docker network. Possible values are
bridge
,host
,overlay
,macvlan
. See network docs for more details. - ingress bool
- Create swarm routing-mesh network. Defaults to
false
. - internal bool
- Whether the network is internal.
- ipam_
configs Sequence[NetworkIpam Config Args] - The IPAM configuration options
- ipam_
driver str - Driver used by the custom IP scheme of the network. Defaults to
default
- ipam_
options Mapping[str, Any] - Provide explicit options to the IPAM driver. Valid options vary with
ipam_driver
and refer to that driver's documentation for more details. - ipv6 bool
- Enable IPv6 networking. Defaults to
false
. - labels
Sequence[Network
Label Args] - User-defined key/value metadata
- name str
- The name of the Docker network.
- options Mapping[str, Any]
- Only available with bridge networks. See bridge options docs for more details.
- scope str
- Scope of the network. One of
swarm
,global
, orlocal
.
- 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
Configs List<Property Map> - The IPAM configuration options
- ipam
Driver String - Driver used by the custom IP scheme of the network. Defaults to
default
- ipam
Options Map<Any> - 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 List<Property Map>
- User-defined key/value metadata
- name String
- The name of the Docker network.
- options Map<Any>
- Only available with bridge networks. See bridge options docs for more details.
- scope String
- Scope of the network. One of
swarm
,global
, orlocal
.
Supporting Types
NetworkIpamConfig, NetworkIpamConfigArgs
- Aux
Address Dictionary<string, object> - 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
- Aux
Address map[string]interface{} - 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
- aux
Address Map<String,Object> - 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
- aux
Address {[key: string]: any} - 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
- aux_
address Mapping[str, Any] - Auxiliary IPv4 or IPv6 addresses used by Network driver
- gateway str
- The IP address of the gateway
- ip_
range str - The ip range in CIDR form
- subnet str
- The subnet in CIDR form
- aux
Address Map<Any> - 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
NetworkLabel, NetworkLabelArgs
Import
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
terraform
resource “docker_network” “foo” {
name = “foo”
}
then the import command is as follows
#!/bin/bash
$ pulumi import docker:index/network:Network foo 87b57a9b91ecab2db2a6dbf38df74c67d7c7108cbe479d6576574ec2cd8c2d73
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Docker pulumi/pulumi-docker
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
docker
Terraform Provider.