On my production environment I have some apps in Docker that need to connect to backing services eg the database on the same host. I found I needed to make an exception in iptables to accept these connections.
However, the ip range of the docker network is varying between restarts. At first it was 172.18.0.0/24, later 172.17.0.0/24 and 172.20.0.0/24, now the ips are 192.168.172.2 and 192.168.192.3.
How can you accept Docker traffic from within a container to say mariadb reliably and safely?
EDIT: An answer seems to be specifying the IPAM configuration, but attaching to an interface seems more elegant