I'm trying to build my code inside a container, so I created a Dockerfile from maven official images and tried to execute maven inside that container, but bash is throwing "Permission denied" when running the mvn command.
I've then tried to isolate the problem and created a very simple Dockerfile:
FROM maven
RUN mvn --version
When I execute this simple Dockerfile, it throws the error on line 2: /bin/sh: /usr/bin/mvn: Permission denied.
So, I've tried to investigate the mvn command permissions inside the container, with this Dockerfile:
FROM maven
RUN ls -la /usr/bin/mvn
RUN ls -la /usr/share/maven/bin/mvn
RUN id ${whoami}
RUN mvn --version
The results:
Sending build context to Docker daemon 11.36MB
Step 1/5 : FROM maven
---> 8ebd3d89902a
Step 2/5 : RUN ls -la /usr/bin/mvn
---> Running in fcd887d9aacf
lrwxrwxrwx 1 root root 24 May 22 02:13 /usr/bin/mvn -> /usr/share/maven/bin/mvn
Removing intermediate container fcd887d9aacf
---> bfd60797390b
Step 3/5 : RUN ls -la /usr/share/maven/bin/mvn
---> Running in 1c7c7f237444
-rwxr-xr-x 1 root root 5741 Nov 7 2019 /usr/share/maven/bin/mvn
Removing intermediate container 1c7c7f237444
---> e3351b0ed7c8
Step 4/5 : RUN id ${whoami}
---> Running in 7a4db16f1831
uid=0(root) gid=0(root) groups=0(root)
Removing intermediate container 7a4db16f1831
---> fe875f847f70
Step 5/5 : RUN mvn --version
---> Running in 0c5eb52d25d9
/bin/sh: /usr/bin/mvn: Permission denied
Removing intermediate container 0c5eb52d25d9
The command '/bin/sh -c mvn --version' returned a non-zero code: 126
Everything seems to be fine: running as root user, files are all owned to root... I'm building it with the command:
docker build --rm --no-cache -t testdocker:latest .
I've tried running it as sudo with the same results, unfortunately.
I'm running with a user with uid=1000, using ubuntu 18.04. Funny thing is it worked for a while, but then it stopped (probably after I've messed with something I shouldn't lol).
Does anybody here have any ideas on how to tackle this situation?