-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Description of feature
The EXPOSE instruction found in a Dockerfile is mostly treated as a comment in today's docker landscape. This is why many official images set it without too much second thought. For example:
- The official nginx image exposes
80/tcp - The official caddy image exposes
2019/tcp 443/tcp 443/udp 80/tcp
These base images are often used as a base layer, upon which users may change the default configuration of ports. However a limitation of docker is that Dockerfile users cannot remove ports exposed by another layer, they can only add extra ports to expose.
The Dokku documentation mentions two types of docker images:
- Applications using EXPOSE: images that have exposed ports, nginx publishes those.
- Applications not using EXPOSE: images that do not have exposed ports, instead they rely on the traditional
PORTenvironment variable.
The documentation then instructs to use DOKKU_DOCKERFILE_PORTS to switch from one type to the other. However it seems that Dokku can only switch from "not expose" to "expose". The opposite does not work.
To reproduce the problem, try to deploy to Dokku this small application that runs a web server on the port given via $PORT:
FROM caddy:2
RUN echo -e ':{$PORT}\nroot * /usr/share/caddy\nfile_server' > /etc/caddy/CaddyfileIt does not work because Dokku uses the exposed port 2019 defined in the base image no matter the configuration of the DOKKU_DOCKERFILE_PORTS setting and no matter the manual port mapping defined.
Therefore it would be good to have a way to explicitly tell Dokku that the ports exposed in the Dockerfile should be ignored, which would make the application fall back to the default PORT behavior.