Docker network commands

List of networks used by docker

  • bridge = default docker virtual network
  • host = network directly connected to the host network card (no NAT)
  • none = network which removes the eth0 of the container and leaves only localhost
docker network ls

Display informations about the network (subnet,…)

docker network inspect {NETWORK_NAME}

Create a new network based on the bridge

docker network create {NEW_NETWORK_NAME}

Create a new container attached to the specified network

docker container run --network {NETWORK_NAME} --name {CONTAINER_NAME} {IMAGE_USED}

Attach an existing container to the specified network

without removing the network already attached.

docker network connect {NETWORK_NAME} {CONTAINER_NAME}

Detach an existing container from the specified network

docker network disconnect {NETWORK_NAME} {CONTAINER_NAME}
Previous
Next