Skip to content

Instantly share code, notes, and snippets.

@prog
Last active September 9, 2022 08:08
Show Gist options
  • Save prog/48341108404cae266d72ed4a470c1bc3 to your computer and use it in GitHub Desktop.
Save prog/48341108404cae266d72ed4a470c1bc3 to your computer and use it in GitHub Desktop.
How to run service in docker-compose as current user
version: '3'
services:
greeter:
image: alpine:latest
volumes:
- "/etc/passwd:/etc/passwd:ro"
- "/etc/group:/etc/group:ro"
environment:
- "USER=${USER}"
command: su -s /bin/sh "${USER}" -c 'echo "Hello, I am $$(whoami)!"; id'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment