Run Container as non root user
- Ngôn ngữ chính
- Go
- Star
- 1.2k
- Fork
- 69
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
**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"
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- docker, docker-compose, go
- Lĩnh vực
- devops, security
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100