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

Request to change port inside container #62

Open
GFNiko opened this issue Jan 27, 2023 · 6 comments
Open

Request to change port inside container #62

GFNiko opened this issue Jan 27, 2023 · 6 comments

Comments

@GFNiko
Copy link

GFNiko commented Jan 27, 2023

As I am using IPVLAN Layer 3 in my docker setup, every microservice gets its own ip address. Therefore I don't need different ports. And docker doesn't support port rebinding in an ipvlan L3. So I want to change the given port 5000 to 80, so I dont have the local dns record of 192.168.10.5:5000 to snip.homelab:5000. Let me change it to 192.168.10.5:80 therefore just http://snip.box please
When I run the docker run command
docker run -d --network=home_lab --ip=192.168.10.5 --name=snippetbox --restart=always -v ~/docker/config:/config pawelmak/snippet-box:latest it binds it to the port 5000, even I put --bind :80 or -p 80:80 to the command. How do I use it without port 5000

@schklom
Copy link

schklom commented Feb 4, 2023

Why not use a different port, like -p 80:5000?
This does not seem like a rare edge case where you need container port 80.

@GFNiko
Copy link
Author

GFNiko commented Feb 5, 2023

Becasue docker's IPVLAN ignores ports

@schklom
Copy link

schklom commented Feb 5, 2023

Oh, I didn't know that.
Unless the dev fixes this, you could link snippet-box to a reverse-proxy and expose the reverse-proxy's port. A basic nginx config would do.

@codesterd
Copy link

I usually just change the EXPOSE port in the Dockerfile and build it.

https://www.mend.io/free-developer-tools/blog/docker-expose-port/

@schklom
Copy link

schklom commented Feb 9, 2023

@codesterd I don't think that is enough. The software needs to listen on that port.
Also, you don't need to build the Dockerfile if all you change is EXPOSE, this can be changed in your docker-compose.yml or docker run command.

@blakeusblade
Copy link

Along the same lines... While defining ports in your docker composer file ie below...

version: '3' services: snippet-box: image: pawelmalak/snippet-box:latest container_name: snippetbox volumes: - /volume1/docker/snippetbox:/app/data ports: - 5212:5813 restart: unless-stopped

The ports gets mapped when defining the ports in the composer file
image

The result doesn't change whats running inside the container as shown by the logs
image

[2024-09-04 05:46:16.021 UTC+0] [INFO] server: Server is working on port 5000 in production mode

In most Synology NAS's, this is very bad because Synology's default port is 5000 and when anything uses that port by default regardless of networking, Synology's have issues...

It would be good to have an environmental variable to be able to define the port that the container will run on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants