flatnotes
flatnotes copied to clipboard
Docker Port revisited
Hello. I'm trying to get flatnotes working on using Docker Compose (Portainer).
I have another container also using port 8080. I found this old issue changing from port 80 to 8080. The last comment makes it sound like there is an environmental variable to change the port. I've tried changing the docker compose PORT to 8282, but the server still starts on 8080.
Am I stuck using this port only?
Hey @aguileraGit 👋.
Inside the container the server always starts on port 8080. But Docker lets you map that internal port to another port outside the container.
When using docker run
the flag would look something like -p 1234:8080
. I've not used Portainer myself but I would imagine you can do something similar?
Hey @dullage. Yes, Portainer provides a way to house multiple Docker Compose files (among others). Instead of having a folder with a bunch of Docker Compose files, it has an interface to organize, store, and edit them. Following the Docker Compose example on the README, -p 1234:8080
should expose port 1234
the same way docker run
works. But it doesn't. When I look at the logs, I see it starting on 8080.
ERROR: [Errno 98] error while attempting to bind on address ('0.0.0.0', 8080): address already in use
This might be a limitation of my setup. I have multiple containers running and using the HOST IP. It just makes it easier for me to load a container using hostIP:port, where each port points to a different container. Except in this case. I'm trying to host multiple containers that have the same internal port (8080).
I think if I changed the networking type, then containers could all use port 8080 and then can be 'mapped' to an external port. I'll do a little more reading.
Based on this from the Portainer docs it looks possible. Let me know how you get on.
I'm going to close this. The issue is specific to running containers with network_mode = HOST
AND services inside containers use the same port.
As a test, I've cloned this repo, changed the port to 8181, built the image, and deployed the container without any errors.
Ideally, an argument port in entrypoint.sh
could be added. This is similar to ${PGID}
and others. This also means moving the HEALTHCHECK from the dockerfile to docker compose. Not sure how that works with just docker.
I'll put a little more effort into this. I rather have docker pull your latest version instead of having to merging updates into my repo and fighting with git since Dockerfile
and entrypoint.sh
differ. Thoughts?