Actual behavior
After the build image using kaniko on a jenkins node maven cannot find the javac.
Expected behavior
After the build of an image using kaniko you must be able to continue use maven and java on a container.
To Reproduce
Steps to reproduce the behavior:
Create a docker image with java, maven and kaniko 1.6.0 inside. In my case I have created a jenkins agent:
FROM gcr.io/kaniko-project/executor:v1.6.0 as kaniko
FROM jenkins/inbound-agent:4.7-1-jdk11
USER root
ENV JAVA_OPTS -XX:-UsePerfData
RUN apt-get update && apt-get install -y --no-install-recommends apt-transport-https ca-certificates gnupg2 software-properties-common maven
COPY --from=kaniko /kaniko /kaniko
RUN cp /kaniko/executor /kaniko/kaniko-executor
COPY ./config.json /kaniko/.docker/
ENV PATH=$PATH:/kaniko
ENV DOCKER_CONFIG=/kaniko/.docker/
WORKDIR /kaniko
Run a container based on the previous docker file.
Build a java project using maven inside of the container previously created.
Build a docker file using kaniko inside of the container previously created.
Try to build again the java project using maven.
The maven has complained cannot find the javac. [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Before to run kaniko build I have executed the following commands:
+ which javac
/usr/local/openjdk-11/bin/javac
**+ javac --version
Picked up _JAVA_OPTIONS: -Djdk.net.URLClassPath.disableClassPathURLCheck=true
javac 11.0.10**
[Pipeline] sh
+ echo ---1-------
+ ls -la /usr/local/openjdk-11/
total 44
drwxr-xr-x 1 root root 4096 Mar 12 23:13 .
drwxr-xr-x 1 root root 4096 Mar 12 23:13 ..
drwxrwxr-x 2 root root 4096 Jan 12 11:31 bin
drwxrwxr-x 4 root root 4096 Jan 12 11:31 conf
drwxrwxr-x 4 root root 4096 Jan 12 11:31 demo
drwxrwxr-x 3 root root 4096 Jan 12 11:31 include
drwxrwxr-x 2 root root 4096 Jan 12 11:31 jmods
drwxrwxr-x 73 root root 4096 Jan 12 11:31 legal
drwxrwxr-x 1 root root 4096 Jan 12 11:31 lib
drwxrwxr-x 4 root root 4096 Jan 12 11:31 man
-rw-rw-r-- 1 root root 1220 Jan 12 11:31 release
+ ls -la /usr/local/openjdk-11/bin/javac
**-rwxrwxr-x 1 root root 13173 Jan 12 11:31 /usr/local/openjdk-11/bin/javac**
After the kaniko build I have executed the same commands:
which javac
/usr/local/openjdk-11/bin/javac
[Pipeline] sh
+ echo ---2-------
+ ls -la /usr/local/openjdk-11/
total 68
drwxr-xr-x 1 root root 4096 Jun 15 00:13 .
drwxr-xr-x 1 root root 4096 Jun 15 00:12 ..
drwxrwxr-x 1 root root 4096 Jun 15 00:13 bin
drwxrwxr-x 1 root root 4096 Jun 15 00:13 conf
drwxrwxr-x 4 root root 4096 Jan 12 11:31 demo
drwxrwxr-x 3 root root 4096 Jan 12 11:31 include
drwxrwxr-x 2 root root 4096 Jan 12 11:31 jmods
drwxrwxr-x 1 root root 4096 Jan 12 11:31 legal
drwxrwxr-x 1 root root 4096 Jun 15 00:13 lib
drwxrwxr-x 1 root root 4096 Jun 15 00:13 man
-rw-rw-r-- 1 root root 999 Apr 9 14:24 release
+ ls -la /usr/local/openjdk-11/bin/javac
-rwxrwxr-x 1 root root 13173 Jan 12 11:31 /usr/local/openjdk-11/bin/javac
+ javac --version
Picked up _JAVA_OPTIONS: -Djdk.net.URLClassPath.disableClassPathURLCheck=true
Error occurred during initialization of boot layer
java.lang.module.FindException: Module jdk.compiler not found
The javac seems to be there but the maven cannot see.
I have tried without kaniko and is working.
For build kaniko image I have used the following command:
Actual behavior After the build image using kaniko on a jenkins node maven cannot find the javac.
Expected behavior After the build of an image using kaniko you must be able to continue use maven and java on a container. To Reproduce Steps to reproduce the behavior:
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Is the same results without cache flag. Additional Information
Dockerfile FROM openjdk:11-jre VOLUME /tmp COPY fileA /root/somefolder/fileA COPY some.jar some.jar COPY app.jar app.jar RUN mkdir -p /root/localFolder/local/system ; \ echo "READY" > /root/localFolder/local/system/status.trigger;
ENTRYPOINT ["java", "some params" "-jar", "/app.jar"]
Build Context Please provide or clearly describe any files needed to build the Dockerfile (ADD/COPY commands)
Kaniko Image (fully qualified with digest)
Triage Notes for the Maintainers
--cache
flag