Skip to content

Docker "label" functionality to limit containers seen in Pangolin UI#61

Closed
JonnyBooker wants to merge 13 commits intofosrl:devfrom
JonnyBooker:docker-label-enable
Closed

Docker "label" functionality to limit containers seen in Pangolin UI#61
JonnyBooker wants to merge 13 commits intofosrl:devfrom
JonnyBooker:docker-label-enable

Conversation

@JonnyBooker
Copy link
Contributor

@JonnyBooker JonnyBooker commented Jun 6, 2025

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_ENABLE to the value of true, that any container without a dedicated new label of newt.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 DEBUG so 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?

  1. A build of newt would be required from this branch, in this instance I have built the dockerfile locally in the root git repository using:
docker build . -t newt:test
  1. Using docker compose below, a valid newt id/secret/endpoint will be required
    Here is an example docker-compose.yml
services:
  newt:
    image: newt:test
    container_name: newt
    restart: unless-stopped
    environment:
      - PANGOLIN_ENDPOINT=<Endpoint Value>
      - NEWT_ID=<ID Value>
      - NEWT_SECRET=<Secret Value>
      - DOCKER_LABEL_ENABLE=true
      - DOCKER_SOCKET=/var/run/docker.sock
    networks:
      - newt-network
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  nginx-example-1:
    image: nginx:latest
    container_name: nginx-example-1
    networks:
      - newt-network
    restart: unless-stopped

  nginx-example-2:
    image: nginx:latest
    labels:
      - newt.docker.enable=true
    container_name: nginx-example-2
    networks:
      - newt-network
    restart: unless-stopped

networks:
  newt-network:

In pangolin, only one container should be visible via the dashboard:
image

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

Output of the debug logs for env variables:
image

@JonnyBooker JonnyBooker marked this pull request as ready for review June 6, 2025 19:53
@JonnyBooker JonnyBooker changed the base branch from main to dev June 9, 2025 12:40
@JonnyBooker
Copy link
Contributor Author

Apologies, targetting the branch incorrectly to begin with, updated now

@JonnyBooker
Copy link
Contributor Author

Closing this PR after discussion on discord in favour of other functionality to control container access in Pangolin

@JonnyBooker JonnyBooker closed this Jun 9, 2025
@JonnyBooker JonnyBooker deleted the docker-label-enable branch June 9, 2025 22:06
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