Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

docker network Command

docker network Command

Docker Command ReferenceDocker Command Reference


docker network The command is used to manage Docker networks. These commands can create, list, delete, and inspect networks, helping users establish communication between Docker containers.

Common docker network Command

  1. docker network ls: List all networks
  2. docker network inspect: View detailed network information
  3. docker network create: Create a new network
  4. docker network rm: Delete one or more networks
  5. docker network connect: Connect a container to a network
  6. docker network disconnect: Disconnect a container from a network

docker network ls Command

List all networks.

docker network ls

Output:

NETWORK ID          NAME                DRIVER              SCOPE

b649b57f5bc5        bridge              bridge              local

7e8c2d2c0b5a        host                host                local

6a9c8d69bfb2        none                null                local

docker network inspect Command

View detailed information of a specified network.

Output:

[

    {

        "Name": "my_network",

        "Id": "b649b57f5bc5",

        "Created": "2024-07-23T00:00:00.000000000Z",

        "Scope": "local",

        "Driver": "bridge",

        "EnableIPv6": false,

        "IPAM": {

            "Driver": "default",

            "Options": {},

            "Config": [

                {

                    "Subnet": "172.18.0.0/16",

                    "Gateway": "172.18.0.1"

                }

            ]

        },

        "Internal": false,

        "Attachable": false,

        "Containers": {},

        "Options": {},

        "Labels": {}

    }

]

docker network create Command

Create a new network.

docker network create my_network

Common parameters

Example:

docker network create --driver bridge --subnet 192.168.1.0/24 my_network

docker network rm Command

Delete one or more networks.

docker network rm my_network

Delete multiple networks:



docker network rm network1 network2

docker network connect Command

Connect a container to a network.

docker network connect my_network my_container

docker network disconnect Command

Disconnect a container from a network.

docker network disconnect my_network my_container

Use Cases

docker network The command set provides powerful network management functions, allowing users to create, configure, and manage network connections between Docker containers. By using these commands, users can achieve isolation, communication, and network configuration between containers to meet various complex networking needs.


Docker Command ReferenceDocker Command Reference