Skip to content

Use NGINX_PORT in place of 80 port #979

Open
@sylvainfaubet

Description

@sylvainfaubet

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions