I'm trying to build a Docker
image using a user other than root
. My Dockerfile
looks like
FROM ruby:2.7.1-alpine3.12
...
# Add user
RUN addgroup --system cetacean && \
adduser --system mobydick --ingroup cetacean --no-create-home
USER mobydick
...
# Copy startup files
COPY --chown=mobydick:cetacean docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY --chown=mobydick:cetacean docker/docker-entrypoint.d/* /docker-entrypoint.d/
COPY --chown=mobydick:cetacean docker/docker-entrypoint.sh /docker-entrypoint.sh
But, when I try to start a container I get:
ERROR: for app Cannot start service app: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: "/docker-entrypoint.sh": permission denied": unknown
From my understanding, using --chown=mobydick:cetacean
when copying the files should set the appropriate permissions.
What am I missing here?