I create docker containers with a node.js app (depends on dockerode API from apocas) with multiple docker networks connected to each container. By default every container gets a random ip address for each network interface.
Example: dev-container with ip: 172.18.0.2 and connected to network demo-net on interface eth4
When I do a docker inspect dev-container
i can see that network demo-net is connected to the container dev-container with ip address 172.18.0.2 (as expected).
Now I execute the dev-container with docker exec -it dev-container /bin/bash
and configure the ip address with ifconfig eth4 192.168.99.169 netmask 255.255.240.0
.
Result: ifconfig
shows that the new address 192.168.99.169 is connected to interface eth4. But when I do a docker inspect dev-container
again, there is still the old address 172.18.0.2 connected with network demo-net (not expected).
Is there a way that docker can update the internal network settings so that docker inspect will show the updated ip settings or is there a better way to change a containers ip address?
(Docker version is 19.03.12)