Skip to content

Instantly share code, notes, and snippets.

@denibertovic
Created November 16, 2021 17:09
Show Gist options
  • Save denibertovic/4c019d2b572453f0b9d18847874abd29 to your computer and use it in GitHub Desktop.
Save denibertovic/4c019d2b572453f0b9d18847874abd29 to your computer and use it in GitHub Desktop.
Docker entrypoint.sh example with docker group for running sibling containers
#!/bin/bash
# Add docker group
groupadd docker --gid ${DOCKER_GROUP_ID:-129}
# Add local user
# Either use the LOCAL_USER_ID if passed in at runtime or
# fallback
# The user is added to the docker group to be able to start containers
USER_ID=${LOCAL_USER_ID:-9001}
echo "Starting with UID : $USER_ID"
useradd --shell /bin/bash -G ${DOCKER_GROUP_ID:-129} -u $USER_ID -o -c "" -m user
export HOME=/home/user
exec /usr/local/bin/gosu user "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment