Created
February 12, 2018 11:41
-
-
Save cristiroma/406a3fc0f55f99576a4b293def2f4067 to your computer and use it in GitHub Desktop.
Connect from docker container to host service (mysqld)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker-compose.yml - creates a new network bridge | |
# listed in `docker network ls`. | |
# Note the name, i.e: `br-f60327d77bc2` | |
services: | |
tomcat: | |
image: tomcat:7.0 | |
networks: | |
- dockernet | |
networks: | |
dockernet: | |
driver: bridge | |
ipam: | |
config: | |
- subnet: 192.168.0.0/24 | |
gateway: 192.168.0.1 | |
# Add iptables firewall rule to allow connection to MySQL running on host system: | |
# Note: MySQL must listen on all interfaces: 0.0.0.0:3306! | |
# Use other iptables rule to limit external traffic to MySQL | |
-A INPUT -p tcp -m state --state NEW -m tcp -i br-f60327d77bc2 --dport 3306 -j ACCEPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment