Networks

List all networks

GET /api/v1/networks

Example request

$ curl -sq -XGET -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/networks

Example response

[
    {
        "Attachable": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Created": "2021-08-11T16:55:07.048985983+08:00",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Config": [
                {
                    "Gateway": "10.0.3.1",
                    "Subnet": "10.0.3.0/24"
                }
            ],
            "Driver": "default",
            "Options": null
        },
        "Id": "ae66e9ed5afcd0d38f7073e0b09712dc36acf76871a6a7ecac9bbddd6ee0ae31",
        "Ingress": false,
        "Internal": false,
        "Labels": {},
        "Name": "bridge",
        "Options": {
            "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": "lxcbr0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Scope": "local"
    },
    {
        "Attachable": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Created": "2021-08-11T16:42:55.906451085+08:00",
        "Driver": "host",
        "EnableIPv6": false,
        "IPAM": {
            "Config": [],
            "Driver": "default",
            "Options": null
        },
        "Id": "f4a43371d6862ed24d70e0e034e06b82bae98866c3ffbaab38407d99dbee4e78",
        "Ingress": false,
        "Internal": false,
        "Labels": {},
        "Name": "host",
        "Options": {},
        "Scope": "local"
    },
    {
        "Attachable": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Created": "2021-08-11T16:42:55.827747036+08:00",
        "Driver": "null",
        "EnableIPv6": false,
        "IPAM": {
            "Config": [],
            "Driver": "default",
            "Options": null
        },
        "Id": "fef81c8f99d720dfb6bfb0bfcf0a4bdd348ad62c5c9a78a96c5a91ee2c27d5e3",
        "Ingress": false,
        "Internal": false,
        "Labels": {},
        "Name": "none",
        "Options": {},
        "Scope": "local"
    }
]

Create a network

POST /api/v1/networks
Request JSON Object:
 
  • name (string) – The new network’s name. this is a mandatory field [required]
  • check_duplicate (bool) – Requests daemon to check for networks with same name
  • driver (string) – Name of the network driver plugin to use. Defaults to bridge driver
  • internal (string) – Restrict external access to the network
  • ipam (object) – Optional custom IP scheme for the network
  • enableIPv6 (bool) – Enable IPv6 on the network [currently not supported]
  • options (object) – Network specific options to be used by the drivers
  • labels (object) – Labels to set on the network, specified as a map: {“key”:”value” [,”key2”:”value2”]} [currently not supported]

Example request

$ curl -sq -XPOST -b cookies.txt -d \
    '{
        "name": "doc_test_network",
        "check_duplicate": true
    }' \
    http://${QIP}:${QPORT}/container-station/api/v1/networks

Example response

{
    "Id": "83941286c6b01cfbfa4c6ca9f2f0b93e92351ccf6ee0931be795b995942b9199",
    "Warning": ""
}

Example response with duplicated network

{
    "error": {
        "code": 400,
        "message": "409 Client Error: Conflict (\"network with name doc_test_network already exists\")"
    }
}

Inspect network

GET /api/v1/networks/(string: network_id)

Display detailed network information.

Parameters:
  • network_id – The network’s id

Example request

$ curl -sq -XGET -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/networks/doc_test_network/inspect

Example response

{
    "Attachable": false,
    "ConfigFrom": {
        "Network": ""
    },
    "ConfigOnly": false,
    "Containers": {},
    "Created": "2021-08-11T17:06:46.538300506+08:00",
    "Driver": "bridge",
    "EnableIPv6": false,
    "IPAM": {
        "Config": [
            {
                "Gateway": "172.29.0.1",
                "Subnet": "172.29.0.0/22"
            }
        ],
        "Driver": "default",
        "Options": null
    },
    "Id": "83941286c6b01cfbfa4c6ca9f2f0b93e92351ccf6ee0931be795b995942b9199",
    "Ingress": false,
    "Internal": false,
    "Labels": {},
    "Name": "doc_test_network",
    "Options": {},
    "Scope": "local"
}

Connect container

POST /api/v1/networks/(string: network_id)/connect

Connect container to a network.

Request JSON Object:
 
  • container (string) – container-id/name to be connected to the network

Example request

$ curl -sq -XPOST -b cookies.txt -d \
    '{"container": "dtest"}' \
    http://${QIP}:${QPORT}/container-station/api/v1/networks/doc_test_network/connect

Example response

{}

Inspect result after container connected

{
    "Attachable": false,
    "ConfigFrom": {
        "Network": ""
    },
    "ConfigOnly": false,
    "Containers": {},
    "Created": "2021-08-11T17:06:46.538300506+08:00",
    "Driver": "bridge",
    "EnableIPv6": false,
    "IPAM": {
        "Config": [
            {
                "Gateway": "172.29.0.1",
                "Subnet": "172.29.0.0/22"
            }
        ],
        "Driver": "default",
        "Options": null
    },
    "Id": "83941286c6b01cfbfa4c6ca9f2f0b93e92351ccf6ee0931be795b995942b9199",
    "Ingress": false,
    "Internal": false,
    "Labels": {},
    "Name": "doc_test_network",
    "Options": {},
    "Scope": "local"
}

Disconnect container

POST /api/v1/networks/(string: network_id)/disconnect

Disconnect container from a network.

Request JSON Object:
 
  • container (string) – container-id/name to be disconnected from a network
  • force (string) – Force the container to disconnect from a network [currently not supported]

Example request

$ curl -sq -XPOST -b cookies.txt -d \
    '{"container": "dtest", "forct": false}' \
    http://${QIP}:${QPORT}/container-station/api/v1/networks/doc_test_network/disconnect

Example response

{}

Remove a network

DELETE /api/v1/networks/(string: network_id)
Parameters:
  • network_id – The network’s id

Example request

$ curl -sq -XDELETE -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/networks/doc_test_network

Example response

{}

Example response of network not found

{
    "error": {
        "code": 400,
        "message": "404 Client Error: Not Found (\"network doc_test_network not found\")"
    }
}

Remove all unused networks

DELETE /api/v1/networks/

Example request

$ curl -sq -XDELETE -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/networks/

Example response

{
    "NetworksDeleted": [
        "doc_test_network_1",
        "doc_test_network_2"
    ]
}
{
    "NetworksDeleted": null
}