Docker container with ip address on local network, p2

In my latest post I described described a way to give a docker container an address on the local network. That’s a general way of achieving it, but it’s also rather complicated. If you know exactly what ports need to be exposed there is a simpler way.

Add a second IP to the system interface

There’s a good description on how to give an interface multiple in Debian at the Debian Wiki. The completely manual way is

ip addr add dev eth0 label eth0:0

The configuration in Debian is

auto eth0:0
iface eth0:0 inet static

If you’re using Systemd it seems to be enough to just add extra Address=... statements to the .network file:



Bind ports of the container to a specific IP

Using the image from my latest post it’s just to run it using the --publish option:

docker --rm --interactive --tty --name=echo --publish= nw /home/myusre/echosrv

Just like the last time it’s easy to verify everything’s working using netcat.

Leave a comment