mirror of
https://github.com/fosrl/newt.git
synced 2026-03-09 07:12:28 -05:00
[PR #61] [CLOSED] Docker "label" functionality to limit containers seen in Pangolin UI #95
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fosrl/newt/pull/61
Author: @JonnyBooker
Created: 6/6/2025
Status: ❌ Closed
Base:
dev← Head:docker-label-enable📝 Commits (10+)
641c7f2Update sha256c423f66Merge pull request #53 from fosrl/devf8653e2Merge remote-tracking branch 'upstream/main'a937027Update flake.nix for 1.2.04a70af4Merge pull request #56 from fosrl/dev21f5aa9Merge remote-tracking branch 'upstream/main'35d82eaUpdate flake.nix for 1.2.150b621fMerge pull request #60 from firecat53/main456ac26Update main.go5473964Update docker client to filter according to label📊 Changes
5 files changed (+0 additions, -0 deletions)
View changed files
📝
README.md(+31 -0)📝
docker/client.go(+18 -7)📝
flake.lock(+4 -4)📝
flake.nix(+3 -3)📝
main.go(+46 -14)📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description
I wanted the ability to be able to limit which containers pangolin can see. I have containers locally that I would not want to expose and seeing them in a list amongst containers that I did felt redundant and I didn't want to give the option in the UI.
Similar to traefik/watchtower, I have added functionality where if a new environment variable is set
DOCKER_LABEL_ENABLEto the value oftrue, that any container without a dedicated new label ofnewt.docker.enable=true, would be ignored and not sent to pangolin. Default not setting of this variable would keep existing behaviour.This does not disable access to the container itself, more disables it from being shown in pangolin, it could still be connected to if you knew the IP address. Therefore if a different name would be preferred, then that would be fine. I was following in the footsteps of other apps. Could have the potential that could call list containers once more to get the enabled one, matching up the IP address of the target against docker containers that are label enabled and reject connecting up this server? Open to suggestions on that one if should that.
I have also made it output the values of the variables being used if the log level is lowered to
DEBUGso you can verify you are seeing the values you expect.I haven't got any experience before today in Go so any conventions/formatting/aspects you would like me to change, I'm completely open. I just wanted to see if could make it happen and offer the option if people wanted it.
How to test?
Here is an example
docker-compose.ymlIn pangolin, only one container should be visible via the dashboard:

Logs will be visible if using a debug log level saying what is and isn't included:

Output of the debug logs for env variables:

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.