Skip to content

Instantly share code, notes, and snippets.

@jomoespe
Created November 26, 2019 22:55
Show Gist options
  • Save jomoespe/168b0baf7ba45c84215b35cad886d0d1 to your computer and use it in GitHub Desktop.
Save jomoespe/168b0baf7ba45c84215b35cad886d0d1 to your computer and use it in GitHub Desktop.
Non-privileged Docker image from scratch
# Non-privileged containers based on the scratch image
# https://medium.com/@lizrice/non-privileged-containers-based-on-the-scratch-image-a80105d6d341
FROM ubuntu AS base
RUN useradd -u 10001 user
RUN mkdir /home/user
FROM scratch
COPY --from=base /etc/passwd /etc/passwd
COPY --from=base /home/user /home/user
USER user
ADD app /
ENTRYPOINT [ "/app" ]
# How to build the container
# docker build -t app .
#
# How to run:
# docker build -t app .
#
# Also you can create an alias, passing aws credentials:
# alias the-app="docker run --rm -ti -v $(HOME)/.aws/credentials:/home/app/.aws/credentials:ro app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment