Network interfaces in docker

1

In VirtualBox we have the network interfaces, for example, bridge, nat, host, etc ...

My question is, in Docker do I expose a port only to the host host? Something that in VirtualBox would be equivalent to the "host-only" interface. The idea here would be a local development environment, isolating the container from the rest of the network.

    
asked by anonymous 27.05.2017 / 05:00

2 answers

1

When you install Docker, three types of network are created that can be queried with the command below:

> docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
0a9cecbcdf3e        bridge              bridge              local
7787cba5673e        host                host                local
2a6fba328597        none                null                local

When you start a container, the default is to use network bridge , where the container will join an isolated NAT network with other containers. This network by default is already isolated from the rest of the network.

The network host in this case will do the opposite of what it looks like. It will make your container have contact with the host network, something like external of the virtualbox.

In addition to these 3 networks you can create networks in> customized to have even more insulation between your containers. More information can be found in the Docker on networks documentation.

    
29.05.2017 / 05:04
0

To do this you need a virtualbox bridge network. However, by not using Docker for Windows you will have an additional work consisting of manual configuration of the port redirection between your host and the virtual machine (Virtualbox). This setting is in the advanced virtual network options.

The rest follows the same docker pattern, exposing ports as parameters of the run or start subcommands, or set in docker-compose.

    
28.05.2017 / 11:47