Search code examples
dockernetwork-programmingdocker-network

Add network interfaces to Docker Image


I'm searching for a way to create multiple loopbacks in my Docker Image.

On a "normal" Ubuntu I call

sudo ifconfig lo:1 10.53.0.2/16 up
sudo ifconfig lo:2 10.53.0.3/16 up
sudo ifconfig lo:3 10.53.1.1/16 up
sudo ifconfig lo:4 10.53.1.2/16 up

to setup my loopbacks, but Docker rejects the commands with this error message:

SIOCSIFADDR: Operation not permitted
SIOCSIFFLAGS: Operation not permitted
SIOCSIFFLAGS: Operation not permitted
SIOCSIFNETMASK: Operation not permitted

I also tried creating networks with

docker network create

but that didn't work either

I'm running Docker version 17.06.0-ce and my Base Image is Ubuntu 14.04.

Maybe someone can help?

Thanks, Chris


Solution

  • By default, containers run with some limitations.

    When start your container, use --cap-add to be able to add sub interfaces:

    docker run --cap-add NET_ADMIN