Search or ask Docker

Create a network

POST /networks/create — Docker Engine API 1.57.

View Markdown
POST/networks/create

Connection and access

API connection and authentication guidance

/v1.57

No HTTP authentication requirement is declared for this operation. Transport access controls can still apply.

Parameters

No parameters are declared.

Request and responses

Request

Network configuration

application/json

Type: object

Attachable

Type: boolean

Globally scoped network is manually attachable by regular containers from workers in swarm mode.
All schema constraints and annotations
{
  "description": "Globally scoped network is manually attachable by regular\ncontainers from workers in swarm mode.\n",
  "example": true,
  "type": "boolean"
}
ConfigFrom

Schema: ConfigReference

Specifies the source which will provide the configuration for this network. The specified network must be an existing config-only network; see ConfigOnly.
All schema constraints and annotations
{
  "$ref": "#/components/schemas/ConfigReference",
  "description": "Specifies the source which will provide the configuration for\nthis network. The specified network must be an existing\nconfig-only network; see ConfigOnly.\n"
}
ConfigOnly

Type: boolean

Creates a config-only network. Config-only networks are placeholder networks for network configurations to be used by other networks. Config-only networks cannot be used directly to run containers or services.
All schema constraints and annotations
{
  "default": false,
  "description": "Creates a config-only network. Config-only networks are placeholder\nnetworks for network configurations to be used by other networks.\nConfig-only networks cannot be used directly to run containers\nor services.\n",
  "example": false,
  "type": "boolean"
}
Driver

Type: string

Name of the network driver plugin to use.
All schema constraints and annotations
{
  "default": "bridge",
  "description": "Name of the network driver plugin to use.",
  "example": "bridge",
  "type": "string"
}
EnableIPv4

Type: boolean

Enable IPv4 on the network.
All schema constraints and annotations
{
  "description": "Enable IPv4 on the network.",
  "example": true,
  "type": "boolean"
}
EnableIPv6

Type: boolean

Enable IPv6 on the network.
All schema constraints and annotations
{
  "description": "Enable IPv6 on the network.",
  "example": true,
  "type": "boolean"
}
IPAM

Schema: IPAM

Optional custom IP scheme for the network.
All schema constraints and annotations
{
  "$ref": "#/components/schemas/IPAM",
  "description": "Optional custom IP scheme for the network."
}
Ingress

Type: boolean

Ingress network is the network which provides the routing-mesh in swarm mode.
All schema constraints and annotations
{
  "description": "Ingress network is the network which provides the routing-mesh\nin swarm mode.\n",
  "example": false,
  "type": "boolean"
}
Internal

Type: boolean

Restrict external access to the network.
All schema constraints and annotations
{
  "description": "Restrict external access to the network.",
  "type": "boolean"
}
Labels

Type: object

User-defined key/value metadata.
All schema constraints and annotations
{
  "additionalProperties": {
    "type": "string"
  },
  "description": "User-defined key/value metadata.",
  "example": {
    "com.example.some-label": "some-value",
    "com.example.some-other-label": "some-other-value"
  },
  "type": "object"
}
Name · required

Type: string

The network's name.
All schema constraints and annotations
{
  "description": "The network's name.",
  "example": "my_network",
  "type": "string"
}
Options

Type: object

Network specific options to be used by the drivers.
All schema constraints and annotations
{
  "additionalProperties": {
    "type": "string"
  },
  "description": "Network specific options to be used by the drivers.",
  "example": {
    "com.docker.network.bridge.default_bridge": "true",
    "com.docker.network.bridge.enable_icc": "true",
    "com.docker.network.bridge.enable_ip_masquerade": "true",
    "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
    "com.docker.network.bridge.name": "docker0",
    "com.docker.network.driver.mtu": "1500"
  },
  "type": "object"
}
Scope

Type: string

The level at which the network exists (e.g. swarm for cluster-wide or local for machine level).
All schema constraints and annotations
{
  "description": "The level at which the network exists (e.g. `swarm` for cluster-wide\nor `local` for machine level).\n",
  "type": "string"
}
All schema constraints and annotations
{
  "properties": {
    "Attachable": {
      "description": "Globally scoped network is manually attachable by regular\ncontainers from workers in swarm mode.\n",
      "example": true,
      "type": "boolean"
    },
    "ConfigFrom": {
      "$ref": "#/components/schemas/ConfigReference",
      "description": "Specifies the source which will provide the configuration for\nthis network. The specified network must be an existing\nconfig-only network; see ConfigOnly.\n"
    },
    "ConfigOnly": {
      "default": false,
      "description": "Creates a config-only network. Config-only networks are placeholder\nnetworks for network configurations to be used by other networks.\nConfig-only networks cannot be used directly to run containers\nor services.\n",
      "example": false,
      "type": "boolean"
    },
    "Driver": {
      "default": "bridge",
      "description": "Name of the network driver plugin to use.",
      "example": "bridge",
      "type": "string"
    },
    "EnableIPv4": {
      "description": "Enable IPv4 on the network.",
      "example": true,
      "type": "boolean"
    },
    "EnableIPv6": {
      "description": "Enable IPv6 on the network.",
      "example": true,
      "type": "boolean"
    },
    "IPAM": {
      "$ref": "#/components/schemas/IPAM",
      "description": "Optional custom IP scheme for the network."
    },
    "Ingress": {
      "description": "Ingress network is the network which provides the routing-mesh\nin swarm mode.\n",
      "example": false,
      "type": "boolean"
    },
    "Internal": {
      "description": "Restrict external access to the network.",
      "type": "boolean"
    },
    "Labels": {
      "additionalProperties": {
        "type": "string"
      },
      "description": "User-defined key/value metadata.",
      "example": {
        "com.example.some-label": "some-value",
        "com.example.some-other-label": "some-other-value"
      },
      "type": "object"
    },
    "Name": {
      "description": "The network's name.",
      "example": "my_network",
      "type": "string"
    },
    "Options": {
      "additionalProperties": {
        "type": "string"
      },
      "description": "Network specific options to be used by the drivers.",
      "example": {
        "com.docker.network.bridge.default_bridge": "true",
        "com.docker.network.bridge.enable_icc": "true",
        "com.docker.network.bridge.enable_ip_masquerade": "true",
        "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
        "com.docker.network.bridge.name": "docker0",
        "com.docker.network.driver.mtu": "1500"
      },
      "type": "object"
    },
    "Scope": {
      "description": "The level at which the network exists (e.g. `swarm` for cluster-wide\nor `local` for machine level).\n",
      "type": "string"
    }
  },
  "required": [
    "Name"
  ],
  "title": "NetworkCreateRequest",
  "type": "object"
}

Response 201

Network created successfully

application/json

Schema: NetworkCreateResponse

Response 400

bad parameter

application/json

Schema: ErrorResponse

Schema example

{
  "message": "Something went wrong."
}

Response 403

Forbidden operation. This happens when trying to create a network named after a pre-defined network, or when trying to create an overlay network on a daemon which is not part of a Swarm cluster.

application/json

Schema: ErrorResponse

Schema example

{
  "message": "Something went wrong."
}

Response 404

plugin not found

application/json

Schema: ErrorResponse

Schema example

{
  "message": "Something went wrong."
}

Response 500

Server error

application/json

Schema: ErrorResponse

Schema example

{
  "message": "Something went wrong."
}

Referenced schemas

#/components/schemas/ConfigReference

#/components/schemas/ErrorResponse

#/components/schemas/IPAM

#/components/schemas/NetworkCreateResponse

Complete operation contract
{
  "operationId": "NetworkCreate",
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "properties": {
            "Attachable": {
              "description": "Globally scoped network is manually attachable by regular\ncontainers from workers in swarm mode.\n",
              "example": true,
              "type": "boolean"
            },
            "ConfigFrom": {
              "$ref": "#/components/schemas/ConfigReference",
              "description": "Specifies the source which will provide the configuration for\nthis network. The specified network must be an existing\nconfig-only network; see ConfigOnly.\n"
            },
            "ConfigOnly": {
              "default": false,
              "description": "Creates a config-only network. Config-only networks are placeholder\nnetworks for network configurations to be used by other networks.\nConfig-only networks cannot be used directly to run containers\nor services.\n",
              "example": false,
              "type": "boolean"
            },
            "Driver": {
              "default": "bridge",
              "description": "Name of the network driver plugin to use.",
              "example": "bridge",
              "type": "string"
            },
            "EnableIPv4": {
              "description": "Enable IPv4 on the network.",
              "example": true,
              "type": "boolean"
            },
            "EnableIPv6": {
              "description": "Enable IPv6 on the network.",
              "example": true,
              "type": "boolean"
            },
            "IPAM": {
              "$ref": "#/components/schemas/IPAM",
              "description": "Optional custom IP scheme for the network."
            },
            "Ingress": {
              "description": "Ingress network is the network which provides the routing-mesh\nin swarm mode.\n",
              "example": false,
              "type": "boolean"
            },
            "Internal": {
              "description": "Restrict external access to the network.",
              "type": "boolean"
            },
            "Labels": {
              "additionalProperties": {
                "type": "string"
              },
              "description": "User-defined key/value metadata.",
              "example": {
                "com.example.some-label": "some-value",
                "com.example.some-other-label": "some-other-value"
              },
              "type": "object"
            },
            "Name": {
              "description": "The network's name.",
              "example": "my_network",
              "type": "string"
            },
            "Options": {
              "additionalProperties": {
                "type": "string"
              },
              "description": "Network specific options to be used by the drivers.",
              "example": {
                "com.docker.network.bridge.default_bridge": "true",
                "com.docker.network.bridge.enable_icc": "true",
                "com.docker.network.bridge.enable_ip_masquerade": "true",
                "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
                "com.docker.network.bridge.name": "docker0",
                "com.docker.network.driver.mtu": "1500"
              },
              "type": "object"
            },
            "Scope": {
              "description": "The level at which the network exists (e.g. `swarm` for cluster-wide\nor `local` for machine level).\n",
              "type": "string"
            }
          },
          "required": [
            "Name"
          ],
          "title": "NetworkCreateRequest",
          "type": "object"
        }
      }
    },
    "description": "Network configuration",
    "required": true,
    "x-codegen-request-body-name": "networkConfig"
  },
  "responses": {
    "201": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/NetworkCreateResponse"
          }
        }
      },
      "description": "Network created successfully"
    },
    "400": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "bad parameter"
    },
    "403": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "Forbidden operation. This happens when trying to create a network named after a pre-defined network,\nor when trying to create an overlay network on a daemon which is not part of a Swarm cluster.\n"
    },
    "404": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "plugin not found"
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "Server error"
    }
  },
  "summary": "Create a network",
  "tags": [
    "Network"
  ]
}