Creating your first user-defined bridge network
Whenever we want to connect one Docker container to another Docker container by the container name, then first we have to create a user-defined network. This is because Docker does not support automatic service discovery on the default bridge network. In this recipe, we will learn how to create our own bridge network.
How to do it…
Execute the docker network
command to create a bridge network with the name as my-bridge-network
, as follows:
$ docker network create my-bridge-network 325bca66cc2ccb98fb6044b1da90ed4b6b0f29b54c4588840e259fb7b6505331
How it works…
Verify whether my-bridge-network
has been created successfully by executing the following command:
$ docker network ls NETWORK ID NAME DRIVER 20dc090404cb bridge bridge 9fa39d9bb674 host host 325bca66cc2c my-bridge-network bridge f36203e11372 none null
To see detailed information about my-bridge-network
, run the docker network inspect
command followed by the network name, as follows:
$ docker...