https://github.com/cbuschka/docker-user-adapting-entrypoint
Proof of Concept - User adapting Entrypoint for Docker
https://github.com/cbuschka/docker-user-adapting-entrypoint
docker entrypoint userns-remap
Last synced: about 2 months ago
JSON representation
Proof of Concept - User adapting Entrypoint for Docker
- Host: GitHub
- URL: https://github.com/cbuschka/docker-user-adapting-entrypoint
- Owner: cbuschka
- License: mit
- Created: 2017-09-11T12:56:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-22T18:51:43.000Z (over 8 years ago)
- Last Synced: 2025-03-05T16:17:24.701Z (over 1 year ago)
- Topics: docker, entrypoint, userns-remap
- Language: Shell
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# User adapting Entrypoint for Docker
Original [repository](https://github.com/cbuschka/docker-user-adapting-entrypoint) at github.
## What does it solve?
### Problem
* run container with current host user uid/gid ("worker user")
* how provide home directory when uid/gid of worker user not known at build time
* how to grant access to docker.socket to worker user
### Solution
- run container and entrypoint as root
- create user/group entry for worker user on startup
- add user to docker group when docker.sock provided
- execute command as worker user
## Build
```
docker build --tag docker-user-adapting-entrypoint:local .
```
## Run
```
# WORKER_ vars are optional
docker run -ri --rm \
-e WORKER_UID=$(id -u) \
-e WORKER_GID=$(id -g) \
-e WORKER_HOME=/home/sweethome \
-e WORKER_NAME=wrkr \
-v volume-in-work-dir:/work \
docker-user-adapting-entrypoint:local bash
```
## Run (with docker access from within container)
```
# WORKER_ vars are optional
docker run -ri --rm \
-e WORKER_UID=$(id -u) \
-e WORKER_GID=$(id -g) \
-e WORKER_HOME=/home/sweethome \
-e WORKER_NAME=wrkr \
-v volume-in-work-dir:/work \
-v /var/run/docker.sock:/var/run/docker.sock \
docker-user-adapting-entrypoint:local bash
```
## License
Written by [Cornelius Buschka](https://github.com/cbuschka).
[MIT License](license)