FreeKB - docker network command (create a network on Linux)
Docker - docker network command (create a network on Linux)

This assumes you have installed Docker on Linux and Docker is running. Before creating a docker network, ensure the host Linux operating system has a firewall deamon running, such as firewalld or iptables. The following command creates a docker network named foo-network.

docker network create foo-network

 

The docker network ls command can be used to display the docker networks.

docker network ls

 

Which should return something like this.

NETWORK ID     NAME           DRIVER      SCOPE
233g3acb112a   foo-network    bridge      local

 

The docker volume inspect command can be used to display the configuration of the network.

docker network inspect foo-network

 

Which should return JSON something like this.

[
 {
  "Name":"foo-network",
  "Id":"xxxxxxxxxxxxxxxxxxxxxxxxxx",
  "Created":"yyyy-mm-ddThh:mm:ss.sss",
  "Scope":"local",
  "Driver":"bridge",
  "EnableIPv6": false,
  "IPAM" {
    "Driver":"default",
    "Options" {},
    "Config": [
      {
        "Subnet": "172.19.0.0/16",
        "Gateway": "172.19.0.1"
      }
    ]
  },
  "Internal": false,
  "Attachable": false,
  "Containers": {},
  "Options": {},
  "Labels": {}
 }
]

 

When using the docker run command to install an image, the --network option can be used to configure the image to use the network, like this.

docker run --network=foo-network bar:latest

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter f64f4 in the box below so that we can be sure you are a human.




Comments