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:

Networking with docker-compose

In this file, we have two services: db and wordpress.

In the WordPress service, we have the ports

Get Beginning DevOps with Docker now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.