Create a network Run in API Explorer

POST /networks/create
application/json

Body Required

Network configuration

  • Name string Required

    The network's name.

  • CheckDuplicate boolean

    Deprecated: CheckDuplicate is now always enabled.

  • Driver string

    Name of the network driver plugin to use.

    Default value is bridge.

  • Internal boolean

    Restrict external access to the network.

  • Attachable boolean

    Globally scoped network is manually attachable by regular containers from workers in swarm mode.

  • Ingress boolean

    Ingress network is the network which provides the routing-mesh in swarm mode.

  • IPAM object
    Hide IPAM attributes Show IPAM attributes object
    • Driver string

      Name of the IPAM driver to use.

      Default value is default.

    • Config array[object]

      List of IPAM configuration options, specified as a map:

      {"Subnet": <CIDR>, "IPRange": <CIDR>, "Gateway": <IP address>, "AuxAddress": <device_name:IP address>}
      
      Hide Config attributes Show Config attributes object
      • Subnet string
      • IPRange string
      • Gateway string
      • AuxiliaryAddresses object
        Hide AuxiliaryAddresses attribute Show AuxiliaryAddresses attribute object
        • * string Additional properties
    • Options object

      Driver-specific options, specified as a map.

      Hide Options attribute Show Options attribute object
      • * string Additional properties
  • EnableIPv6 boolean

    Enable IPv6 on the network.

  • Options object

    Network specific options to be used by the drivers.

    Hide Options attribute Show Options attribute object
    • * string Additional properties
  • Labels object

    User-defined key/value metadata.

    Hide Labels attribute Show Labels attribute object
    • * string Additional properties

Responses

  • 201 application/json

    No error

    Hide response attributes Show response attributes object
    • Id string

      The ID of the created network.

    • Warning string
  • 400 application/json

    bad parameter

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

  • 403 application/json

    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.

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

  • 404 application/json

    plugin not found

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

  • 500 application/json

    Server error

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

POST /networks/create
curl \
 --request POST 'http://api.example.com/v1.44/networks/create' \
 --header "Content-Type: application/json" \
 --data '{"IPAM":{"Config":[{"Subnet":"172.20.0.0/16","Gateway":"172.20.10.11","IPRange":"172.20.10.0/24"},{"Subnet":"2001:db8:abcd::/64","Gateway":"2001:db8:abcd::1011"}],"Driver":"default","Options":{"foo":"bar"}},"Name":"isolated_nw","Driver":"bridge","Labels":{"com.example.some-label":"some-value","com.example.some-other-label":"some-other-value"},"Ingress":false,"Options":{"com.docker.network.driver.mtu":"1500","com.docker.network.bridge.name":"docker0","com.docker.network.bridge.enable_icc":"true","com.docker.network.bridge.default_bridge":"true","com.docker.network.bridge.host_binding_ipv4":"0.0.0.0","com.docker.network.bridge.enable_ip_masquerade":"true"},"Internal":true,"Attachable":false,"EnableIPv6":true,"CheckDuplicate":false}'
Request examples
{
  "IPAM": {
    "Config": [
      {
        "Subnet": "172.20.0.0/16",
        "Gateway": "172.20.10.11",
        "IPRange": "172.20.10.0/24"
      },
      {
        "Subnet": "2001:db8:abcd::/64",
        "Gateway": "2001:db8:abcd::1011"
      }
    ],
    "Driver": "default",
    "Options": {
      "foo": "bar"
    }
  },
  "Name": "isolated_nw",
  "Driver": "bridge",
  "Labels": {
    "com.example.some-label": "some-value",
    "com.example.some-other-label": "some-other-value"
  },
  "Ingress": false,
  "Options": {
    "com.docker.network.driver.mtu": "1500",
    "com.docker.network.bridge.name": "docker0",
    "com.docker.network.bridge.enable_icc": "true",
    "com.docker.network.bridge.default_bridge": "true",
    "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
    "com.docker.network.bridge.enable_ip_masquerade": "true"
  },
  "Internal": true,
  "Attachable": false,
  "EnableIPv6": true,
  "CheckDuplicate": false
}
Response examples (201)
{
  "Id": "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30",
  "Warning": ""
}
Response examples (201)
{
  "Id": "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30",
  "Warning": ""
}
Response examples (400)
{
  "message": "Something went wrong."
}
Response examples (400)
{
  "message": "Something went wrong."
}
Response examples (403)
{
  "message": "Something went wrong."
}
Response examples (403)
{
  "message": "Something went wrong."
}
Response examples (404)
{
  "message": "Something went wrong."
}
Response examples (404)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}