0

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?

Sig
  • 5,476
  • 10
  • 49
  • 89

1 Answers1

0

What is the version of docker you are using. This is working only for version v17.09.0-ce and newer as explain here. If your are usin an older version, you can copy then change the permission.

Cyril G.
  • 1,879
  • 2
  • 5
  • 19
  • Thanks for the reply. Not sure why but after rebuilding everything seems ok. Cheers – Sig Sep 23 '20 at 06:49