这是indexloc提供的服务,不要输入任何密码
Skip to content

Allow to ignore ports exposed in Dockerfile #5596

@NicolasLM

Description

@NicolasLM

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 PORT environment 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/Caddyfile

It 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions