Docker Community Forums

Share and learn in the Docker community.

Issue with getting permission to access directories added to a container


(Cyberst) #1

I am having a lot of issues trying to find the answer to the problems I am having with setting up a container, and then accessing files I want to use for testing of that container. I started off with trying the docker cp command, but when the file was copied it was copied as root so I was unable to access it under the separate user I created. I then tried to perform the task in the Dockerfile with COPY and ADD but that also was given me permission issues. I’ve tried numerous things on the internet such as chown, but I cannot figure this out.

RUN useradd -s /bin/bash -m test
COPY . /home/test/
RUN chown -R test /home/test/test_directory

(Joshnw) #2

It’s hard to tell from the snippet posted. Please post the entire Dockerfile along with the docker run command you are using to create and run the container with.