Docker Community Forums

Share and learn in the Docker community.

Change ip address of a running container or at start time

Hi all,

I would like to know if there is any way to set the ip address of an existing container, not with the run option which creates a new one.

I’m working in a solution to do some checks per VLAN so app boots and then switch between a list of vlans and do some tasks per vlan. As I understood by reading networking documentation I should do:
1-Create a new macvlan, set ip address, netmask and gw
2-Create a new container add it to macvlan network and set the IP address
3-Wait until the container is created and booted up
4-Do the tasks
5-Remove the container
6-Remove the network
7-Repeat steps 1 to 6 per each vlan

I need the container to appear as a real device on the network, and to be able to routre traffic to it. The ideal flow i’m looking for is:
1-Create and boot a container or start it if already exists
2-From the host, sweep the list of vlans doing:
2.1-Configure a vlan interface on the container, set ip…
2.2-Remove the vlan interface
3-Repeat steps 2.1, 2.2 per each vlan
4-stop the container
5-Get the report

With lxc I can do it like that, on the fly, without the need to stop or create the container. So is there any way to do that with Docker?

Thanks