Handle docker’s variable ip in iptables
Solution 1:
Two options:
First
Allow access from the docker0
interface rather than for a specific IP range.
iptable -A INPUT -i docker0 -dport 3306
Second
Move the database into a container.
Create a docker named network
Make sure all containers are attached to the named network. You should then be able to access the database container by name from any other container (on the same network).
If you need to access the database externally you can map the port and setup what ever iptables rules you want to secure it.