I am creating a folder inside my Dockerfile and I want to give it a write permission. But I am getting permission denied error when I try to do it
FROM python:2.7 RUN pip install Flask==0.11.1 RUN useradd -ms /bin/bash admin USER admin COPY app /app WORKDIR /app RUN chmod 777 /app CMD ["python", "app.py"]
My error is
PS C:\Users\Shivanand\Documents\Notes\Praneeth's work\Flask> docker build -t shivanand3939/test . Sending build context to Docker daemon 209.9kB Step 1/8 : FROM python:2.7 ---> 8a90a66b719a Step 2/8 : RUN pip install Flask==0.11.1 ---> Using cache ---> 6dc114bd7cf1 Step 3/8 : RUN useradd -ms /bin/bash admin ---> Using cache ---> 1cfdb6eea7dc Step 4/8 : USER admin ---> Using cache ---> 27c5e8b09f15 Step 5/8 : COPY app /app ---> Using cache ---> 5d628573b24f Step 6/8 : WORKDIR /app ---> Using cache ---> 351e19a5a007 Step 7/8 : RUN chmod 777 /app ---> Running in aaad3c79e0f4 **chmod: changing permissions of ‘/app’: Operation not permitted The command '/bin/sh -c chmod 777 /app' returned a non-zero code: 1**
How can I give write permissions to app folder inside my Docker container
How to Mount Local Directories using docker run -v. Using the parameter -v allows you to bind a local directory. -v or --volume allows you to mount local directories and files to your container. For example, you can start a MySQL database and mount the data directory to store the actual data in your mounted directory.
Run Hub docker container Note that pressing `Ctrl+C` when the terminal is attached to a container output causes the container to shut down. Use `Ctrl+PQ` in order to detach the terminal from container output.
I guess you are switching to user "admin" which doesn't have the ownership to change permissions on /app directory. Change the ownership using "root" user. Below Dockerfile worked for me -
FROM python:2.7 RUN pip install Flask==0.11.1 RUN useradd -ms /bin/bash admin COPY app /app WORKDIR /app RUN chown -R admin:admin /app RUN chmod 755 /app USER admin CMD ["python", "app.py"]
PS - Try to get rid of "777" permission. I momentarily tried to do it in above Dockerfile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With