Docker Networking

The default network structure in #Docker is bridge or could be understood as Docker host’s internal network. Such network is private to the public which means that we need to map the port of the Docker container to the Docker host’s port where the clients will access. This could be done by adding the option -p {client-access-port}:{app-listen-port} to docker run.

Instead of using the Docker default bridge, we could create our own bridge by calling docker network create --driver bridge --subnet {ip/mask} {network-name}.

We could override the default network option with --network={network-type} to docker run. There are two available network types that Docker could recognise: none and host.

With none, the container is truly private to the Docker host where no port mapping is valid. This means that the application is not accessible from any one other than the host itself.

With host, the container’s port is now not isolated from the host’s network stack. This means that the container could be directly accessed even without additional port mapping. However, we could not run multiple containers in a Docker host with this networking setting.

The domain name resolution is done by Docker’s built-in Domain Name Server (DNS)# server which is running at 127.0.0.11.

Links to this page
#container #networking