0

I recently started learning Docker.

I have inquired about relevant information

And added User

But still Permission denied

What am I doing wrong? Can you help me?

Dockerfile

FROM python:3.7-alpine
WORKDIR /usr/src/app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN addgroup -S app && adduser -S -G app app
USER app
RUN apk add tzdata && /usr/share/zoneinfo/Asia/Taipei /etc/localtime && echo "Asia/Taipei" > /etc/timezone && apk del tzdata
RUN apk update && apk add python3-dev gcc libc-dev libffi-dev libwebp-dev
RUN apk add --no-cache jpeg-dev zlib-dev ffmpeg
RUN apk add --no-cache --virtual .build-deps build-base linux-headers 
COPY requirements.txt .
RUN python3 -m pip install --upgrade pip && pip install -r requirements.txt 
COPY . /usr/src/app

log

 > [ 4/10] RUN apk add tzdata && /usr/share/zoneinfo/Asia/Taipei /etc/localtime && echo "Asia/Taipei" > /etc/timezone && apk del tzdata:
#8 0.417 ERROR: Unable to lock database: Permission denied
#8 0.418 ERROR: Failed to open apk database: Permission denied
dudulu
  • 754
  • 6
  • 17
  • I refer to this article, adding `RUN addgroup -S app && adduser -S -G app app` `USER app` still doesn't work. – dudulu Dec 04 '21 at 16:01
  • What is the final goal - to install package as user app or have user to be app when the container is running? if the latter, you can just move you `USER app` directive below the `apk add` statements. – jabbson Dec 04 '21 at 16:22
  • I want users to use this application. – dudulu Dec 04 '21 at 16:39
  • 1
    Use this to set the timezone `RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime && echo "Asia/Taipei" > /etc/timezone` and move your USER statement down after the `apk add`s. See if this works. – jabbson Dec 04 '21 at 17:08

0 Answers0