0

I have a problem with the file permission in the docker image

Dockerfile

FROM ubuntu

ENV PATH="/scripts:${PATH}"

RUN apt update -y

RUN apt-get install debconf-utils

RUN apt install python3.8 -y

RUN apt install python3-pip -y

RUN echo 'tzdata tzdata/Areas select Europe' | debconf-set-selections
RUN echo 'tzdata tzdata/Zones/Europe select Paris' | debconf-set-selections
RUN DEBIAN_FRONTEND="noninteractive" apt install -y tzdata

RUN apt-get install -y gdal-bin
RUN apt-get install -y libgdal-dev

COPY ./requirements.txt /requirements.txt

RUN pip install -r requirements.txt

RUN mkdir /app

COPY ./app /app

WORKDIR /app

COPY ./scripts /scripts

RUN chmod +x /scripts/*

RUN mkdir -p /vol/web/media

RUN mkdir -p /vol/web/static
RUN mkdir -p /vol/web/media
RUN adduser --disabled-password user
-->(error line)RUN chown -R user:user /vol
RUN chmod -R 755 /vol/web

USER user

CMD ["entrypoint.sh"]

The fourth line from the last is where I'm giving permission for the user. But I when I tried running the docker it shows the following error

PermissionError: [Errno 13] Permission denied: '/vol/web/static'

I also don’t know what group is user and I'm a newbie

swamper
  • 117
  • 1
  • 10
  • You are not showing how the directory is mounted, but you can't change the ownership of a directory outside your container. – tripleee Aug 24 '21 at 10:44
  • The `tzdata` lines configure the time zone, not `gdal-bin`. You have to figure out what `dpkg-get-selections` the pagkage provides, and add those instead. (This is related to an earlier question by the OP.) – tripleee Aug 24 '21 at 10:46
  • @tripleee I'm full newbie in this please could answer me in the previous question? – swamper Aug 24 '21 at 10:49
  • I have no knowledge about `gdal-bin` but the question I linked as a duplicate there has a link to the Debian preseeding documentation. In brief, try something like `dpkg-get-selections | grep gdal` on a host where the package is properly installed, and put those instead of the `tzdata` lines. Compare with `dpkg-get-selections | grep tzdata` to see how they relate. – tripleee Aug 24 '21 at 10:52
  • @tripleee gdal-bin ask nothing but the timezone in which the docker is not interactive while building an image and that's all the problem is with previous question. I don't know that this `dpkg-get-selection` does could you please explain me this? – swamper Aug 24 '21 at 11:12
  • `dpkg-set-selections` tells `dpkg` "here are the configuration values to use, so you don't have to ask". Similarly `dpkg-get-selections` allows you to query the current values, and optionally save them for `dpkg-set-selections` to use later on. It's a utility you need to install separately, from the `debconf-utils` package. Again, see the duplicates you were already pointed to, and in particular https://stackoverflow.com/a/22466739/874188 – tripleee Aug 24 '21 at 12:34

0 Answers0