Describe the bug
Can't build docker native image with the application, can't even copy pom.xml to the build image (quay.io/quarkus/centos-quarkus-maven:19.3.1-java11) it looks like an issue with the image because I can copy files into my own Docker images, even based on CentOS.
Expected behavior
Build application into docker container image
Actual behavior
Docker build fails in first stage
To Reproduce
Steps to reproduce the behavior:
$ docker build -t quay.io/fabstao/rokostacio2 .
Sending build context to Docker daemon 3.584kB
Step 1/20 : FROM quay.io/quarkus/centos-quarkus-maven:19.3.1-java11 AS build
19.3.1-java11: Pulling from quarkus/centos-quarkus-maven
524b0c1e57f8: Pull complete
1beb771cdd17: Pull complete
Digest: sha256:f83fc08a9b5594df9681a60c156d41e0b225eece3889f4eb299b01684ab5696c
Status: Downloaded newer image for quay.io/quarkus/centos-quarkus-maven:19.3.1-java11
---> 0b3da81f4a33
Step 2/20 : COPY pom.xml /project/pom.xml
COPY failed: stat /var/lib/docker/tmp/docker-builder136156981/pom.xml: no such file or directory
$
Configuration
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/centos-quarkus-maven:19.3.1-java11 AS build
COPY pom.xml /usr/src/app/
RUN mvn -f /usr/src/app/pom.xml -B de.qaware.maven:go-offline-maven-plugin:1.2.5:resolve-dependencies
COPY src /usr/src/app/src
USER root
RUN chown -R quarkus /usr/src/app
USER quarkus
RUN mvn -f /usr/src/app/pom.xml -Pnative clean package
## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY --from=build /usr/src/app/target/*-runner /work/application
# set up permissions for user `1001`
RUN chmod 775 /work /work/application \
&& chown -R 1001 /work \
&& chmod -R "g+rwX" /work \
&& chown -R 1001:root /work
EXPOSE 8080
USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
$ docker build -t quay.io/fabstao/rokostacio2 .
Sending build context to Docker daemon 3.584kB
Step 1/15 : FROM quay.io/quarkus/centos-quarkus-maven:19.3.1-java11 AS build
---> 0b3da81f4a33
Step 2/15 : COPY pom.xml /usr/src/app/
COPY failed: stat /var/lib/docker/tmp/docker-builder336411649/pom.xml: no such file or directory
md5-931b96b36912c60085295f0aa4c0f508
$ uname -a
Linux deb10 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64 GNU/Linux
md5-69f380b1bc841e13b4be5cd20bef69f4
$ docker version
Client:
Version: 18.09.1
API version: 1.39
Go version: go1.11.6
Git commit: 4c52b90
Built: Tue, 03 Sep 2019 19:59:35 +0200
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.09.1
API version: 1.39 (minimum version 1.12)
Go version: go1.11.6
Git commit: 4c52b90
Built: Tue Sep 3 17:59:35 2019
OS/Arch: linux/amd64
Experimental: false
Please help
Hi @fabstao,
I should have a look at the .dockerignore file. The file has the following content by default.
*
!target/*-runner
!target/*-runner.jar
!target/lib/*
As you can see, all files are ignored (i.e. pom file) except the artifacts. Hence, you have to adjust the rules according to your needs (e.g. add !pom.xml).
Oh got it, now it's working, thanks a lot!
Most helpful comment
Oh got it, now it's working, thanks a lot!