Skip to content
Advertisement

Multiple ip on same interface in Docker container

Is that possible to have multiple IPs on eth0 in a Docker container?

I would like having 5 IPs on eth0 in a Docker container interface. I am using “ip” utility. Executing ip address add 172.20.0.200/16 dev eth0 in the container give “Operation not permited.

  • I tried manually log to the container as root user using “sudo exec -u root ..”.
  • I have even tried apt-install sudo in the container. Result is same “Operation not permitted”

Advertisement

Answer

I have found the answer. There must be added –cap-add option docker run --cap-add=NET_ADMIN image

But as I understand docker know nothing about static IPs since docker network inspect shows only one IP. Hence think of using custom network

Advertisement