Skip to content

Use NGINX_PORT in place of 80 port #979

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

Open
sylvainfaubet opened this issue Apr 17, 2025 · 1 comment
Open

Use NGINX_PORT in place of 80 port #979

sylvainfaubet opened this issue Apr 17, 2025 · 1 comment
Labels

Comments

@sylvainfaubet
Copy link

Bug Overview

The NGINX container documentation mentions an NGINX_PORT environment variable.

However, there appears to be no mention of this variable in the container code.
This can be confusing when trying to change the default port 80 to another one using this variable, as the NGINX container continues to expose port 80.

This causes problems when paired with the Traefik proxy, which uses the lowest-exposed port.

Expected Behavior

When I set env variable NGINX_PORT to 8080, the only exposed port is 8080.

Steps to Reproduce the Bug

execute : docker run -d -e NGINX_PORT=8080 nginx
the result is :

CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS     NAMES
f48cd10e623e   nginx     "/docker-entrypoint.…"   2 seconds ago   Up 2 seconds   80/tcp    nostalgic_spence

the result should be :

CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS     NAMES
f48cd10e623e   nginx     "/docker-entrypoint.…"   2 seconds ago   Up 2 seconds   8080/tcp    nostalgic_spence

Environment Details

  • Version/release of Docker and method of installation (e.g. Docker Desktop / Docker Server)
  • Version of the Docker NGINX image or specific commit: [e.g. 1.4.3/commit hash]
  • Target deployment platform: [e.g. OpenShift/Kubernetes/Docker Compose/local cluster/etc...]
  • Target OS: [e.g. RHEL 9/Ubuntu 24.04/etc...]

Additional Context

I think I have misunderstood the documentation, reading "Using environment variables in nginx configuration (new in 1.19)" in https://hub.docker.com/_/nginx
It could be an error or mistake to show NGINX_PORT variable in documentation if it is not used by the container, it's confusing.

providing a variable who can change the default port is a real feature envy !

@oxpa
Copy link
Collaborator

oxpa commented Apr 17, 2025

Hello @sylvainfaubet

NGINX_PORT is used to showcase template function in the image. By default there is no default.conf.template in the image.
You will have to create a template before using it.

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

No branches or pull requests

2 participants