Networking with docker-compose
By default, docker-compose
sets up a single network for your application(s) where each container can reach and discover other containers.
The network is given a name based on the name of the directory it lives in. Thus, if your directory is called py_docker
, when your run docker-compose up
, the network created is called py_docker_default
.
We mentioned ports in the previous topic, when creating the WordPress container. To explain networking better, we'll use the docker-compose.yml
used to spin up a WordPress application:
In this file, we have two services: db
and wordpress
.
In the WordPress service, we have the ports
option mapping port 80
to port 8000
. No wonder, the WordPress app runs on 0.0.0.0:8000
on our browsers.
The ports option is not in the db
service. However, if you go to the docker hub page for mysql
, you'll notice that port 3306
is exposed. This is the standard port for MySQL. You can obtain more information on MySQL from: https://hub.docker...