Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of EXPOSE causes unnecessary port being opened when changing port from default #707

Open
Nbelles opened this issue Mar 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Nbelles
Copy link

Nbelles commented Mar 19, 2024

Describe the bug

Hello,

I'm having some issues with using the default port that is exposed. Once this port is exposed, there is no way to unexpose it or hide it. It is much preferable for a project to choose an arbitrary port (like the standard 80 and 443) for inside the container that users can then map to any port they want outside the container (using docker compose). By using the EXPOSE command in the docker file, even if you map another port through a docker compose file and you use a nonstandard port inside the container, you still get an extra exposed port 8080 which might collide with other containers running that also natively expose port 8080.

EXPOSE ${PORT}

What do you see?

When I use the normal docker run -p 9000:8080 --name gatus twinproduction/gatus command, everything works as expected with only port 9000 being exposed. But when I use a docker-compose.yml file and a custom internal port of 4443 for https in the config.yml file, the EXPOSE line causes port 8080 to be exposed in addition to the selected port in the docker-compose.yml. Here's an example docker-compose.yml and config.yml that shows this problem.

docker-compose.yml

version: "3"
services:
  gatus:
    image: twinproduction/gatus:latest
    ports:
      - "9000:4443"
    volumes:
      - ./config:/config

./config/config.yml

endpoints:
    ...
web:
  port: 4443

docker ps output with extra port 8080

PORTS                            
8080/tcp, 0.0.0.0:9000->4443/tcp

What do you expect to see?

I would prefer to only have the port that is selected in my docker compose file to be exposed. I believe this would be resolved by removing the line here:

EXPOSE ${PORT}

(This is one of many docker services that I have found that expose this port).

List the steps that must be taken to reproduce this issue

Example described in "What do you see?"

Version

twinproduction/gatus:latest

Additional information

No response

@Nbelles Nbelles added the bug Something isn't working label Mar 19, 2024
@betocolon23
Copy link

I have this same problem, I tried to build a new image doing ENV PORT=8081 in the Dockerfile but it didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants