Linux Labs

Containers: Docker and compose / Stage 7 of 11

Container networking: names and ports

Not running Starting usually ~20 s
Leave the lesson

Step 6 of 6 · summary · 2 min

Summary

  • On Docker's default network (bridge) containers see each other by address and ask the host's DNS servers for names — and those servers do not know container names.
  • In a network of your own (docker network create) Docker's DNS at 127.0.0.11 answers with the names of that network's containers.
  • A container joins a network when it is created (--network) or on the fly (docker network connect).
  • A neighbour connects by name and by the port of the program inside the container; a published port is the entrance from the host.
  • app wrote bad address 'db' because both containers were on the default network: there was nobody to ask about the name db.
Ubuntu 24.04
Loading…