I am building a Docker image based on Oracle Linux 6.7.
It seems the default permissions of the /
directory created is incorrect: 750. I want to change it to 755 but the chmod
command in the Dockerfile seems to have no effect.
How do I set the permissions of the /
directory? I have tried adding
USER root
in the Dockerfile but that did not work either.
Dockerfile
FROM oraclelinux:6.7
RUN ls -ld /
RUN chmod 755 /
RUN ls -ld /
Output from docker build -t oraclelinux:fubar .
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM oraclelinux:6.7
---> cfc75fa9f295
Step 1 : RUN ls -ld /
---> Running in ed83a5c1f462
drwxr-x--- 21 root root 4096 Aug 27 14:41 /
---> 2a1f11648594
Removing intermediate container ed83a5c1f462
Step 2 : RUN chmod 755 /
---> Running in 6f045908c424
---> 1e44793993cb
Removing intermediate container 6f045908c424
Step 3 : RUN ls -ld /
---> Running in 0b1b10022e79
drwxr-x--- 21 root root 4096 Aug 27 14:41 /
---> f97f3e6711c5
Removing intermediate container 0b1b10022e79
Successfully built f97f3e6711c5
If I run the container and change the permissions manually, it works:
docker run -ti oraclelinux:fubar
[root@1e73ebab4b8c /]# ls -ld /
drwxr-x--- 21 root root 4096 Aug 27 14:56 /
[root@1e73ebab4b8c /]# chmod 755 /
[root@1e73ebab4b8c /]# ls -ld /
drwxr-xr-x 21 root root 4096 Aug 27 14:56 /
I found out after searching on the web that the main problem was about the '/' directory having incorrect permissions and it could not be fixed by simply changing the permissions inside the Dockerfile.
This post suggested that it could be related to umask
and the bug fix went into the 1.8.0 release. So, the first step was to upgrade the Docker engine. It did not solve the problem.
Another post suggested that when an image was built on one file system and then used on another, the permissions on the '/' directory are set incorrectly. On the system I was building the image, 'devicemapper' is used. It could be that the image from Dockerhub was built on a different file system.
So, I switched to a different Oracle Linux image, provided by Oracle:
FROM oracle/oraclelinux:6.6
and it fixed the problem.
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