Skip to content

feat: filter containers seen by docker-gen #623

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

buchdag
Copy link
Member

@buchdag buchdag commented May 17, 2024

The PR add the -container-filter option to filter the containers that docker-gen will see.

The option work pretty much like -notify-filter and can be used multiple times to combine filters with AND.

This:

docker-gen \
    -container-filter status=running \
    -container-filter label=com.github.nginx-proxy.nginx \
    ./some/template.tmpl ./result.ext

will result in docker-gen only seeing running container that possess the label com.github.nginx-proxy.nginx.

Closes #276

Unfortunately Docker filter options for containers does not provide negative filtering, so #117, #210, and #252 won't be entirely fixed by this.

Thanks @tarasov65536 for the inspiration.

@buchdag buchdag self-assigned this May 17, 2024
@buchdag buchdag marked this pull request as draft May 17, 2024 16:55
flag.BoolVar(&notifyOutput, "notify-output", false, "log the output(stdout/stderr) of notify command")
"only include containers with published ports (implies -only-exposed). Bypassed when providing a container published filter (-container-filter published=foo).")
flag.BoolVar(&includeStopped, "include-stopped", false,
"include stopped containers. Bypassed by when providing a container status filter (-container-filter status=foo).")
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
"include stopped containers. Bypassed by when providing a container status filter (-container-filter status=foo).")
"include stopped containers. Bypassed when providing a container status filter (-container-filter status=foo).")

-include-stopped
include stopped containers
only include containers with published ports (implies -only-exposed).
Bypassed by when providing a container published filter (-container-filter published=foo).
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
Bypassed by when providing a container published filter (-container-filter published=foo).
Bypassed when providing a container published filter (-container-filter published=foo).

-notify-signal signal
signal to send to the -notify-container and -notify-filter. -1 to call docker restart. Defaults to 1 aka. HUP.
All available signals available on the dockerclient
https://github.com/fsouza/go-dockerclient/blob/main/signal.go
-only-exposed
only include containers with exposed ports
only include containers with exposed ports.
Bypassed by when using the exposed filter with (-container-filter exposed=foo).
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
Bypassed by when using the exposed filter with (-container-filter exposed=foo).
Bypassed when using the exposed filter with (-container-filter exposed=foo).

-endpoint string
docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock
-include-stopped
include stopped containers.
Bypassed by when providing a container status filter (-container-filter status=foo).
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
Bypassed by when providing a container status filter (-container-filter status=foo).
Bypassed when providing a container status filter (-container-filter status=foo).

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

Successfully merging this pull request may close these issues.

Docker stack filter
1 participant