liveBook · Manning

Docker network

As explained in Rust Servers, Services, and Apps

A Docker network is a Docker-managed virtual network that enables communication between containers and other network endpoints.

A Docker network connects containers so application components can communicate. In a web-service deployment, a shared network links the tutor service and its Postgres database. section 12.3.1 section 12.5

Connect the tutor service and database

Create `tutor-network`, connect `tutor-webservice` and `tutor-postgres`, then inspect the network. The deployment uses `tutor-postgres` as the database host in `DATABASE_URL`. section 12.3.1 section 12.5

"Containers": {
  "26a5fc9ac00d815cb933bf66755d1fd04f6dca1efe1ffbc96f28da50e65238ba": {
    "Name": "tutor-postgres",
    "EndpointID":
    "e870c365731463198fbdf46ea4a7d22b3f9f497727b410852b86fe1567c8a3e6",
    "MacAddress": "02:42:ac:1b:00:03",
    "IPv4Address": "172.27.0.3/16",
    "IPv6Address": ""
   },
  "af6e823821b36d13bf1b381b2b427efc6f5048386b4132925ebd1ea3ecfa5eaa": {
    "Name": "tutor-webservice",
    "EndpointID":
    "015e1dbc36ae8e454dc4377ad9168b6a01cae978eac4e0ec8e14be98d08b4f1c",
    "MacAddress": "02:42:ac:1b:00:02",
    "IPv4Address": "172.27.0.2/16",
    "IPv6Address": ""
   }
},

Inspect output lists both containers attached to the network and their assigned IP addresses. section 12.5

How Rust Servers, Services, and Apps covers it

How deep it goes
Demonstrates creating, connecting, and inspecting a network, but does not explain networking internals.
Examples
Uses the tutor web service and Postgres containers, with `tutor-network` and a database URL naming the database container.
What you can do after
Operate a shared container network by creating it, connecting containers, and inspecting its membership.
How it connects
Links Docker Compose, Docker containers, and PostgreSQL in a web-service deployment.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.