Docker Engine 29 reference · Volumes, Networks and Disk Usage
docker network Command (Docker CLI)
Create and manage networks; containers on the same user-defined network reach each other by name.
Docker Engine 29
Syntax
docker network create|ls|inspect|connect|disconnect|rm [OPTIONS] NETWORK
Parameters
| Parameter | Description |
|---|---|
create NAME |
Create a bridge network. |
connect NETWORK CONTAINER |
Attach a running container. |
rm NAME |
Remove a network. |
Examples
docker network create rc-ref-net > /dev/null
docker run -d --name rc-ref-srv --network rc-ref-net redis:8-alpine > /dev/null; sleep 1
docker run --rm --network rc-ref-net redis:8-alpine redis-cli -h rc-ref-srv ping
docker rm -f rc-ref-srv > /dev/null; docker network rm rc-ref-net > /dev/null
Output
PONG
Run this on your computer — see “Get Started” for setup.
docker network create --subnet 172.30.42.0/24 rc-ref-net2 > /dev/null
docker network inspect rc-ref-net2 --format '{{.Driver}} {{(index .IPAM.Config 0).Subnet}}'
docker network rm rc-ref-net2 > /dev/null
Output
bridge 172.30.42.0/24
Run this on your computer — see “Get Started” for setup.
Related
docker volume· Create, list, inspect and remove named volumes, the Docker-managed storage that outlives containers.docker run· Create and start a container from an image, with options for ports, environment, volumes, names and cleanup.- Container Networks and DNS · tutorial