Skip to content

[bitnami/nginx] Add worker_processes env var#91159

Merged
fmulero merged 7 commits intobitnami:mainfrom
jhthompson:main
Apr 8, 2026
Merged

[bitnami/nginx] Add worker_processes env var#91159
fmulero merged 7 commits intobitnami:mainfrom
jhthompson:main

Conversation

@jhthompson
Copy link
Copy Markdown
Contributor

@jhthompson jhthompson commented Feb 27, 2026

Description of the change

Add a NGINX_WORKER_PROCESSES environment variable to control the value of the Nginx worker_processes directive.

Benefits

Ability to better control resource usage

Nginx's worker_processes auto creates too many worker processes in certain deployments. This change provides an easy hook to manually set the number to a more sensible value. From a currently open issue on Nginx itself:

Currently, if one uses worker_processes auto;, nginx uses sysconf(_SC_NPROCESSORS_ONLN) to detect the number of available processes.

In environments, such as Kubernetes or OpenShift, this causes issues, as it returns the cores available to the system and not the actual services available to the service.

This is a solved problem in the docker-nginx image by providing an entrypoint script to "tune" the value to something more appropriate, but adding a similar approach here feels heavy-handed.

Corrects existing documentation

It is not possible to override worker_processes via the listed method in the Readme, as Nginx errors with a "duplicate directive" since it ends up being present twice.

Possible drawbacks

If NGINX_WORKER_PROCESSES is currently set in any deployments that use this image, there may be unexpected behavior.

Applicable issues

n/a

Additional information

Various issues across several Nginx projects are related to this:

@github-actions github-actions bot added nginx triage Triage is needed labels Feb 27, 2026
@github-actions github-actions bot requested a review from javsalgar February 27, 2026 19:58
Signed-off-by: Jeremy Thompson <23730407+jhthompson@users.noreply.github.com>
@carrodher carrodher added verify Execute verification workflow for these changes in-progress labels Mar 2, 2026
@github-actions github-actions bot removed the triage Triage is needed label Mar 2, 2026
@github-actions github-actions bot removed the request for review from javsalgar March 2, 2026 09:26
@github-actions github-actions bot requested a review from fmulero March 2, 2026 09:26
@jhthompson
Copy link
Copy Markdown
Contributor Author

jhthompson commented Mar 2, 2026

Some outputs from my local testing (if relevant). All commands ran from bitnami/nginx/1.29/debian-12):

Building the image locally:

docker build -t nginx-local:$(git rev-parse --short HEAD) --build-arg TARGETARCH=amd64 .

No env var

docker run nginx-local:80ceba9418a   
nginx 20:28:22.37 INFO  ==> 
nginx 20:28:22.37 INFO  ==> Welcome to the Bitnami nginx container
nginx 20:28:22.37 INFO  ==> 
nginx 20:28:22.38 INFO  ==> ** Starting NGINX setup **
nginx 20:28:22.40 INFO  ==> Validating settings in NGINX_* env vars
Certificate request self-signature ok
subject=CN = example.com
nginx 20:28:23.91 INFO  ==> No custom scripts in /docker-entrypoint-initdb.d
nginx 20:28:23.92 INFO  ==> Initializing NGINX
realpath: /bitnami/nginx/conf/vhosts: No such file or directory
nginx 20:28:23.96 INFO  ==> ** NGINX setup finished! **

nginx 20:28:23.98 INFO  ==> ** Starting NGINX **

(from running container):

nginx -T
nginx: the configuration file /opt/bitnami/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/bitnami/nginx/conf/nginx.conf test is successful
# configuration file /opt/bitnami/nginx/conf/nginx.conf:
# Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
# user              www www;  ## Default: nobody

worker_processes  auto; # <------------------- relevant line here
error_log         "/opt/bitnami/nginx/logs/error.log";
pid               "/opt/bitnami/nginx/tmp/nginx.pid";

include  "/opt/bitnami/nginx/conf/context.d/main/*.conf";
# ... more below ...

With valid env var

docker run -e NGINX_WORKER_PROCESSES=1 nginx-local:80ceba9418a
nginx 20:33:37.26 INFO  ==> 
nginx 20:33:37.26 INFO  ==> Welcome to the Bitnami nginx container
nginx 20:33:37.27 INFO  ==> 
nginx 20:33:37.27 INFO  ==> ** Starting NGINX setup **
nginx 20:33:37.30 INFO  ==> Validating settings in NGINX_* env vars
Certificate request self-signature ok
subject=CN = example.com
nginx 20:33:41.25 INFO  ==> No custom scripts in /docker-entrypoint-initdb.d
nginx 20:33:41.25 INFO  ==> Initializing NGINX
realpath: /bitnami/nginx/conf/vhosts: No such file or directory
nginx 20:33:41.30 INFO  ==> ** NGINX setup finished! **

nginx 20:33:41.32 INFO  ==> ** Starting NGINX **

(from running container):

nginx -T
nginx: the configuration file /opt/bitnami/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/bitnami/nginx/conf/nginx.conf test is successful
# configuration file /opt/bitnami/nginx/conf/nginx.conf:
# Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
# user              www www;  ## Default: nobody

worker_processes  1; # <------------------- relevant line here
error_log         "/opt/bitnami/nginx/logs/error.log";
pid               "/opt/bitnami/nginx/tmp/nginx.pid";

include  "/opt/bitnami/nginx/conf/context.d/main/*.conf";
# ... more below ...

With invalid env var

docker run -e NGINX_WORKER_PROCESSES=aut nginx-local:80ceba9418a
nginx 20:35:31.23 INFO  ==> 
nginx 20:35:31.23 INFO  ==> Welcome to the Bitnami nginx container
nginx 20:35:31.24 INFO  ==> 
nginx 20:35:31.24 INFO  ==> ** Starting NGINX setup **
nginx 20:35:31.26 INFO  ==> Validating settings in NGINX_* env vars
nginx 20:35:31.26 ERROR ==> The allowed values for NGINX_WORKER_PROCESSES are: auto or a positive integer
docker run -e NGINX_WORKER_PROCESSES=-2 nginx-local:80ceba9418a
nginx 20:35:46.13 INFO  ==> 
nginx 20:35:46.13 INFO  ==> Welcome to the Bitnami nginx container
nginx 20:35:46.13 INFO  ==> 
nginx 20:35:46.14 INFO  ==> ** Starting NGINX setup **
nginx 20:35:46.16 INFO  ==> Validating settings in NGINX_* env vars
nginx 20:35:46.16 ERROR ==> The allowed values for NGINX_WORKER_PROCESSES are: auto or a positive integer

Signed-off-by: Jeremy Thompson <23730407+jhthompson@users.noreply.github.com>
Signed-off-by: Jeremy Thompson <23730407+jhthompson@users.noreply.github.com>
@jhthompson
Copy link
Copy Markdown
Contributor Author

@fmulero @carrodher sorry for the ping! Just checking in to see if anyone has had a chance to look at this yet, and if there's anything I should add/remove/change.

@jhthompson
Copy link
Copy Markdown
Contributor Author

@fmulero @carrodher sorry for another ping - is there anything I can do to help move things along on this?

fmulero
fmulero previously approved these changes Apr 8, 2026
Copy link
Copy Markdown
Collaborator

@fmulero fmulero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @jhthompson for your contribution and sorry for my very late response

LGTM

Comment thread bitnami/nginx/README.md Outdated
Signed-off-by: Fran Mulero <francisco-jose.mulero@broadcom.com>
@fmulero fmulero enabled auto-merge (squash) April 8, 2026 10:57
@fmulero fmulero merged commit 3a84f4e into bitnami:main Apr 8, 2026
7 checks passed
@jhthompson
Copy link
Copy Markdown
Contributor Author

jhthompson commented Apr 10, 2026

Thanks @fmulero ! Is this expected to be available on Docker Hub soon? nvm I see the changes are there! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nginx solved verify Execute verification workflow for these changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants