When creating a new container, docker will also create a new IP address. I'd need this IP address for the config file of my stunnel.
In other words, how do I setup stunnel with docker properly?
If you're setting up stunnel inside the container, you can just run ip addr show eth0
to get your ip address:
/ # ip addr show eth0
61: eth0@if62: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
link/ether 02:42:ac:11:00:13 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.19/16 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::42:acff:fe11:13/64 scope link
valid_lft forever preferred_lft forever
If you're setting up stunnel somewhere with access to the Docker API, you can use docker inspect
:
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' mycontainer
172.17.0.20
If you're trying to do something else, please update your question to be more explicit.