Answer the question
In order to leave comments, you need to log in
How to forward mysql container to web server container?
db:
image: mysql:5.7
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=nimda2017
- MYSQL_USER=october
- MYSQL_PASSWORD=secret
- MYSQL_DATABASE=myAppDB
web:
image: igontarev/php-server
ports:
- "80:80"
- "443:443"
links:
- db
volumes:
- ./www:/var/www
- ./sites:/etc/nginx/sites-enabled
- ./logs/nginx:/var/log/nginx
- ./logs/php:/var/log/php
- ./cron:/etc/cron.d
- ./supervisor:/etc/supervisor/conf.d
- ./letsencrypt:/etc/letsencrypt
- ./lib/letsencrypt:/var/lib/letsencrypt
Answer the question
In order to leave comments, you need to log in
Here you have it written in the description of the web
links service:
- db
####
It would be more correct and clear to write
links:
- db:db
)
####
this means who the "db" service container for the "web" service will be available on address db
localhost inside the container will point to this container itself, host ip to the host itself. Of course, you can get to the database using the host IP, because the port is forwarded (which is what your mysql workbench does), but apparently the docker adds this iptables rule only for external networks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question