DELAPARRA
Index
Color
NL
Category: Docker

ports

Explained by Updated

What is ports?

ports: Publishes container ports to the host, mapping HOST:CONTAINER. The Compose equivalent of docker run -p. In Docker Compose, ports publishes container ports on the host, written as "8080:80", host port first. It is the Compose version of docker run -p. Services that only need to talk to each other do not need published ports at all. Inside the Compose network, the app reaches the database at mysql:3306 without any mapping. Publish ports only for what you need to reach from your own machine or the outside world.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about ports

What should you keep in mind with ports?

Quote port mappings in YAML, because unquoted values like 22:22 can be read as numbers in base 60 by some YAML parsers. On shared or public servers, bind to localhost, such as "127.0.0.1:8080:80", and put a reverse proxy in front for public traffic. That keeps databases and admin tools off the internet.

What does an example of ports look like?

services: web: ports: - "8080:80"

At a glance

CategoryDocker
Explained by
Updated

More Docker terms

All terms starting with P

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.