Reputation: 13556
I using the following Dockerfile
to extend a docker image:
FROM solr:6.6
COPY --chown=solr:solr ./services-core/search/A12Core /A12Core/
Note that solr:6.6
has a USER solr
statement.
When running a container built from that Dockerfile I get a permission denied when trying to access a file or directory under /A12Core
:
$ docker run -it 2f3c58f093e6 /bin/bash
solr@c091f0cd9127:/opt/solr$ cd /A12Core
solr@c091f0cd9127:/A12Core$ cd conf
bash: cd: conf: Permission denied
solr@c091f0cd9127:/A12Core$ ls -l
total 8
drw-r--r-- 3 solr solr 4096 Aug 31 14:21 conf
-rw-r--r-- 1 solr solr 158 Jun 28 14:25 core.properties
solr@c091f0cd9127:/A12Core$ whoami
solr
solr@c091f0cd9127:/A12Core$
What do I need to do in order to get permission to access the fiels and folders in the /A12Core
directory?
Note that I'm running the docker build from windows 7. My docker version is 18.03.0-ce
.
Upvotes: 2
Views: 8334
Reputation: 14210
I had another answer here, which was wrong (but still solved your problem :), but now I see the typo in your Dockerfile. Let's take a look at this line.
COPY --chown=solr:solr ./services-core/search/A12Core /A12Core/
The COPY
command checks if the target path in the container exists. If not, it creates it, before copying.
A12Core
from ./services-core/search
./A12Core
exists.root:root
.A12Core
to newly created A12Core
.In the end your have everything in /A12Core
, but it belongs to root
and you can't access it.
Since solr
docker image already sets USER solr
, the way to go would be
RUN mkdir /A12Core
COPY ./services-core/search/A12Core /A12Core
As the docs say
The
USER
instruction sets the user name ... the user group ... for anyRUN
,CMD
andENTRYPOINT
instructions that follow it in theDockerfile
.
Upvotes: 1
Reputation: 263746
Your directory does not have execute permission:
drw-r--r-- 3 solr solr 4096 Aug 31 14:21 conf
Without that, you cannot cd into the directory according to Linux filesystem permissions. You can fix that in your host with a chmod:
chmod +x conf
If you perform this command inside your Dockerfile (with a RUN
line), it will result in any modified file being copied to a new layer, so if you run this recursively, it could double the size of your image, hence the suggestion to fix it on your build host if possible.
Upvotes: 3