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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

docker network create|ls|inspect|connect|disconnect|rm [OPTIONS] NETWORK

Parameters

ParameterDescription
create NAME Create a bridge network.
connect NETWORK CONTAINER Attach a running container.
rm NAME Remove a network.

Examples

Name resolution on a user-defined network
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.

A network with a fixed subnet
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.

Was this page helpful?