Skip to content

Add container filtering feature#2659

Closed
eorea wants to merge 3 commits into
nginx-proxy:mainfrom
eorea:main
Closed

Add container filtering feature#2659
eorea wants to merge 3 commits into
nginx-proxy:mainfrom
eorea:main

Conversation

@eorea

@eorea eorea commented Sep 11, 2025

Copy link
Copy Markdown

This feature allows the filtering of containers with an specific label, those containers that have the filtering label defined would be the ones that would become available for processing.

The feature is fully backwards compatible, if no filtering label is provided via CONTAINER_FILTER_LABEL environment variable all containers in the docker host will be considered for processing.

4 test scenarios has been included, 2 to validate new behavior in both single o multiple instance setups, and 2 to validate the backwards compatible scenarios with the feature not enabled also in both single o multiple instance setups.

The scenarios identified where using this filtering is helpful are:

  • Docker engine running huge number of containers not required to be proxied. Shortening the unfiltered container list from the very beginning helps to reduce processing time in further container list iterations.
  • Multiple nginx-proxy instances. Assigning different filtering labels to different instances of nginx-proxy allows them to proxy independent services within the same docker engine. This also has the benefit to split responsibilities for scenarios requiring split external and internal facing proxies. In cases where a service is required to be proxied in multiple nginx-proxy instances it suffices only to add all the respective filtering labels to the service's container definition.

@p12tic

p12tic commented Sep 14, 2025

Copy link
Copy Markdown
Contributor

#2660 also implements support for a similar use case by using a different approach. The VIRTUAL_HOST and VIRTUAL_HOST_MULTIPORTS environment variables are made configurable for each of the different nginx-proxy instances.

I have no opinion on which approach is better.

@eorea

eorea commented Sep 14, 2025

Copy link
Copy Markdown
Author

FYI, seems that docker_gen will be also implementing filtering using labels by end of month nginx-proxy/docker-gen#276 this will achieve the exact same thing as this PR, and CONTAINER_FILTER_LABEL variable could be used to filter straight from docker_gen instead of doing it at the templating

@p12tic

p12tic commented Sep 14, 2025

Copy link
Copy Markdown
Contributor

Great, seems my PR is not needed then.

@buchdag

buchdag commented Oct 19, 2025

Copy link
Copy Markdown
Member

Closing, since this is now handled by docker-gen directly using the DOCKER_CONTAINER_FILTERS environment variable.

Documentation is here #2667

@buchdag buchdag closed this Oct 19, 2025
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

Successfully merging this pull request may close these issues.

3 participants