Running container as if it were on physical network

Post Reply
valerij
New here
Posts: 3
Joined: Wed Feb 01, 2017 6:08 pm

Running container as if it were on physical network

Post by valerij »

How can I run a container as if it was on the same network as the NAS? On my PC I can do this by creating macvlan network and then creating a container on that network.

Code: Select all

desktop ~ $ ifconfig
eth0	Link encap:Ethernet  HWaddr 00:08:9B:F7:DB:5B
		inet addr:10.0.0.10  Bcast:10.0.0.255  Mask:255.255.255.0
		UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
		RX packets:217672 errors:0 dropped:0 overruns:0 frame:0
		TX packets:327887 errors:0 dropped:0 overruns:0 carrier:0
		collisions:0 txqueuelen:1000
		RX bytes:97712405 (93.1 MiB)  TX bytes:381469137 (363.7 MiB)

desktop ~ $ docker network create -d macvlan --subnet 10.0.0.0/8 --gateway 10.0.0.1 -o parent=eth0 -o macvlan_mode=bridge macvlan
desktop ~ $ docker run --cap-add=NET_ADMIN -e ServerIP=10.0.0.20 --net macvlan --name pihole --restart=always -d diginc/pi-hole:alpine
This will run the pihole container at 10.0.0.20 and it is reachable for all my physical devices running at the 10.0.0.0/24 network. However, I can't do this on my TS-251 since you need docker version 1.12 to create docker macvlan network. So I tried to do it inside docker-in-docker container using

Code: Select all

nas ~ $ docker run --name dind --net host --privileged -d docker:dind dockerd --host=unix:///var/run/docker.sock --storage-driver vfs --iptables=false --bridge=none
inside it I was able to create the macvlan network, but I cant actually start a container on it:

Code: Select all

dind ~ $ docker run --cap-add=NET_ADMIN -e ServerIP=10.0.0.20 --net macvlan --name pihole --restart=always -d diginc/pi-hole:alpine
7ec9bc1c0846f13f0c0b71b85a120f1b6c37925cc4d84b566b2e94bdbf6d811f
docker: Error response from daemon: failed to create the macvlan port: operation not supported.
Any tips on how I can do this?
HorstSeehofer
New here
Posts: 3
Joined: Mon Jan 07, 2019 4:02 am

Re: Running container as if it were on physical network

Post by HorstSeehofer »

I got this to work with the "qnet" driver provided by QNAP:

Code: Select all

docker network create --driver=qnet --ipam-driver=qnet --ipam-opt=iface=bond0 --subnet 192.168.1.0/24 --gateway 192.168.1.1 qnet-static-bond0
I hope that helps someone who stumbles upon this topic.
dobe77
New here
Posts: 4
Joined: Mon Mar 18, 2019 4:57 am

Re: Running container as if it were on physical network

Post by dobe77 »

That looks interesting. How did you create the bond0 network interface? I tried to create vlan interfaces with vconfig. However creating a docker network failed

docker network create -d qnet --ipam-driver=qnet --ipam-opt=iface=eth0.10 qnet-eth0.10
Error response from daemon: IpamDriver.RequestPool: Qnet add interface "eth0.10" to a bridge failed
RussellNS
New here
Posts: 3
Joined: Wed Jul 03, 2019 4:22 am

Re: Running container as if it were on physical network

Post by RussellNS »

dobe77 wrote: Mon Mar 18, 2019 5:00 am That looks interesting. How did you create the bond0 network interface? I tried to create vlan interfaces with vconfig. However creating a docker network failed

docker network create -d qnet --ipam-driver=qnet --ipam-opt=iface=eth0.10 qnet-eth0.10
Error response from daemon: IpamDriver.RequestPool: Qnet add interface "eth0.10" to a bridge failed
I know I'm a bit late to respond here, however, thread helped me solve the same problem. To answer the "How did you create the bond0 network interface' question, I don't think he did create a 'bond0' network interface. I believe QTS configures bond# interfaces automagically based on both the physical network interfaces and based on the user configurations in the 'Network & Virtual Switch'. My assumption is that @HorstSeehofer was just using the 'qnet' driver to create a Docker 'macvlan' network that was bound to the 'bond0' interface that's already there.

My 2c on that is, I couldn't get that to work with 'bond0'. However, using a Google search of 'docker qnet', I did run across this:

https://qnap-dev.github.io/container-st ... /qnet.html

This appears to be the QNAP documentation for the 'qnet' driver used by the Container Station app. Using the information in this site, I was able to get this to work with 'eth0'. The end result for me was this command:

Code: Select all

docker network create -d qnet --ipam-driver=qnet --ipam-opt=iface=eth0 --subnet=12.34.56.0/24 --gateway=12.34.56.1 pub_net
Post Reply

Return to “Container Station”