YouTip LogoYouTip

Docker Network Command

# docker network command [![Image 3: Docker Command Manual](#)Docker Command Manual](#) * * * The `docker network` command is used to manage Docker networks. These commands can create, list, remove, and inspect networks, helping users establish communication between Docker containers. ### Common `docker network` Commands 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 local7e8c2d2c0b5a host host local6a9c8d69bfb2 none null local ### `docker network inspect` Command View detailed information for the 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** * **`--driver`**: Specify the network driver (e.g., `bridge`, `host`, `overlay`). * **`--subnet`**: Specify subnet. * **`--gateway`**: Specify gateway. * **`--ip-range`**: Specify available IP address range. * **`--ipv6`**: Enable IPv6. * **`--label`**: Add labels for the network. 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 * **Container Communication**: Through custom networks, containers can securely communicate with each other across different hosts. * **Isolated Environments**: Use different networks to isolate container environments for improved security. * **Advanced Network Configuration**: Use bridge, overlay, and other network drivers to implement complex network topologies. The `docker network` command set provides powerful network management capabilities, allowing users to create, configure, and manage network connections between Docker containers. By using these commands, users can achieve container isolation, communication, and network configuration to meet various complex network requirements. * * Docker Command Manual](#)
← Zig TutorialCpp Libs Cstdlib β†’