Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

## `Dockerfile`

When building an image that is running some services,
use the [`EXPOSE` directive](https://docs.docker.com/engine/reference/builder/#expose),
to document which ports the services are listening to.
When building an image that will be run by one (or many) container(s) providing (the same) services,
use the [`EXPOSE` directive](https://docs.docker.com/engine/reference/builder/#expose)
with mandatory ports only,
to document which ports the services are necessarily listening to. If the image will be used to run many
containers, some of which don't listen on a port, instead use the `expose` option in
`docker-compose.yml` (see the below section for details) or the `--expose` flag to `docker run`.
Comment on lines +7 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with mandatory ports only,
to document which ports the services are necessarily listening to. If the image will be used to run many
containers, some of which don't listen on a port, instead use the `expose` option in
`docker-compose.yml` (see the below section for details) or the `--expose` flag to `docker run`.
only when **all** containers using this image will listen on that port, to document that all services
will be listening on that port. If the image will be used to run many
containers, some of which don't listen on a port, instead use the `expose` option in
`docker-compose.yml` (see the below section for details) or the `--expose` flag to `docker run`
on only the containers which listen on the port.

Some tools ([such as the nginx proxy companion](https://github.com/nginx-proxy/acme-companion#step-3---proxied-containers))
use it to define a contract between different containers too.
Not using this directive doesn’t prevent exposing those ports to the Docker network.
Expand Down