Network interfaces on Docker

Asked

Viewed 485 times

1

In Virtualbox we have the network interfaces, for example, bridge, Nat, with host, etc...

My question is, can Docker expose a host-only port? 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.

2 answers

1


When installing Docker three types of network which can be consulted 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 starting a container, the default is to use the network bridge, where the container will join an isolated NAT network with other containers. This network by default is already isolated of the rest of the network.

To 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 similar to the external virtualbox.

Beyond these 3 Networks it is possible to create Networks customized to have even more isolation between your containers. More information you can consult the documentation of Docker about Networks.

  • 1

    Thanks for the clarification.

0

To do this you need a Virtualbox bridge network. However, by not using Docker for Windows you will have an additional job that consists of manually setting up port forwarding between your host and the virtual machine (Virtualbox). This setting is in the advanced virtual network options.

The rest follow the same Docker pattern, expose ports as parameters of run or start subcommands, or set in Docker-Compose.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.