Use of EXPOSE causes unnecessary port being opened when changing port from default
Nbelles opened this issue · comments
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.
Line 19 in 5aa83ee
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:
Line 19 in 5aa83ee
(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
I have this same problem, I tried to build a new image doing ENV PORT=8081
in the Dockerfile but it didn't work.