0xfurai / 0xfurai/peekaping

Run Container as non root user

Open
#163 1 comment 4 reactions 0 assignees View on GitHub
to-triage
Dominant language
Go
Stars
1.2k
Forks
69
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

For security concerns i would like to run the container as a non root user.

**Describe the solution you'd like**

Possibillity to provide a `GID` and `UID` enviroment variable for the docker container.
To still have access to the docker socket one could then use [docker-socket-proxy](https://github.com/Tecnativa/docker-socket-proxy) instead of using the socket directly.

It also would be beneficial to provide the host for the dockerproxy as a env variable to peekaping. For example one could set `DOCKERPROXY_HOST` and this gets then selected and pre-filled as the default option when creating docker monitors.

I have attached a example compose.yaml and .env file for it to work with the discussed env vars added (altough they dont do anything atm of course).

I really like the project so far, it looks really good and already has a ton of features!

compose.yaml
```yaml
services:
dockerproxy:
image: ghcr.io/tecnativa/docker-socket-proxy:latest
container_name: dockerproxy
env_file: .env
ports: []
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: unless-stopped
networks:
- internal
peekaping-bundle:
image: 0xfurai/peekaping-bundle-postgres:latest
container_name: peekaping
restart: unless-stopped
ports:
- 8383:8383
env_file: .env
volumes:
- ./data/postgres:/var/lib/postgresql/data
networks:
- internal
depends_on:
- dockerproxy
networks:
internal: {}
```

.env
```.env
## Docker Proxy
CONTAINERS=1
SERVICES=1
TASKS=1
POST=0

## DB
DB_NAME=peekaping
DB_USER=peekaping
DB_PASS=secure_test_password_123

## General
GID=1000
UID=1000
TZ="Europe/Berlin"
DOCKERPROXY_HOST="http://dockerproxy:2375"
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Look at the Dockerfile and entrypoint scripts to see how the container currently runs. Identify where user/group IDs are set and where the Docker socket is accessed. The change involves modifying the container to accept GID and UID environment variables and adjusting the configuration to optionally use a docker-socket-proxy host. Check the code that creates Docker monitors to pre-fill the DOCKERPROXY_HOST. Test by building the image with the new environment variables and verifying it runs as a non-root user.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, go
Domain
devops, security
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.