akoeltringer
akoeltringer

Reputation: 1721

Docker Networking and VLANs

I have a question regarding docker networking over (host) VLAN interfaces.

I tried to ssh out of a docker container to a server over a VLAN network, but the connection could not be established (time-out).

Setting:

I have two machines (lets call them server and laptop) connected by

I tried to connect from a container on the laptop to the server via SSH, using the private network

Diagnostics steps:

So the problem seems to be related to "docker and vLANs": wireshark moreover suggests that "outgoing" is possible, but "incoming" not.

Any ideas?

Upvotes: 3

Views: 16328

Answers (1)

David
David

Reputation: 3055

At the moment the best option to do that is using the (currently) experimental feature "Ipvlan Network".

The Linux implementations are extremely lightweight because rather than using the traditional Linux bridge for isolation, they are simply associated to a Linux Ethernet interface or sub-interface to enforce separation between networks and connectivity to the physical network.

The documentation is quite large and can't be copied here, however, once installed the experimental version, to create the ipvlan network and run a container attaching to it you should run:

Ipvlan

docker network  create -d ipvlan \
  --subnet=192.168.1.0/24 \ 
  --gateway=192.168.1.1 \
  -o ipvlan_mode=l2 \
  -o parent=eth0 db_net

Start a container on the db_net network

docker  run --net=db_net -it --rm alpine /bin/sh

On that page there is much more to read.

Few notes:

  1. -o ipvlan_mode= defaults to L2 mode if not specified

  2. The containers cannot ping the underlying host interfaces as they are intentionally filtered by Linux for additional isolation.

  3. Experimental means it's considered not ready for production and could have some bugs. The documentation states that it's "provided for test and evaluation in your sandbox environments."

Upvotes: 3

Related Questions