Search code examples
dockerintellij-ideadockerfilejetbrains-idedocker-image

IntelliJ Docker: Error response from daemon: COPY failed: no source files were specified


Hello everyone and happy New Year! :-)

I'm totally new to Docker and I tried to build an docker image from my Java project. To build my project, I used IntelliJ with Maven and Quarkus.

These are the versions of Maven, Quarkus and JDK that I used:

IntelliJ IDEA 2023.2.2
Build #IU-232.9921.47, built on September 12, 2023,
openJDK 17.0.8
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<maven.compiler.release>17</maven.compiler.release>
<quarkus.platform.version>3.5.0</quarkus.platform.version>

IntelliJ creates a Dockerfile by itself:

Dockerfile.native:

FROM quay.io/quarkus/quarkus-micro-image:2.0
WORKDIR /work/
RUN chown 1001 /work \
    && chmod "g+rwX" /work \
    && chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application

EXPOSE 8080
USER 1001

ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]

The problem:

If I try to build an docker-image with IntelliJ, I got this error:

Deploying '<unknown> Dockerfile: src/main/docker/Dockerfile'…
Building image…
Preparing build context archive…
[==================================================>]6/6 files
Done

Sending build context to Docker daemon…
[==================================================>] 3,105kB
Done

Step 1/7 : FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8
 ---> 7a93e51a9917
Step 2/7 : WORKDIR /work/
 ---> Using cache
 ---> 2b40db798417
Step 3/7 : RUN chown 1001 /work     && chmod "g+rwX" /work     && chown 1001:root /work
 ---> Using cache
 ---> 32543c06ff9a
Step 4/7 : COPY --chown=1001:root target/*-runner /work/application
Error response from daemon: COPY failed: no source files were specified
Failed to deploy '<unknown> Dockerfile: src/main/docker/Dockerfile': Can't retrieve image ID from build stream

Project structure

I don't understand the problem. If someone could explain it to me, I would be very happy.

Thanks for reading

I tried to search for a solution via Google and StackOverflow. I tried the other Dockerfiles created by IntelliJ:

Dockerfile.native.micro:

FROM quay.io/quarkus/quarkus-micro-image:2.0
WORKDIR /work/
RUN chown 1001 /work \
    && chmod "g+rwX" /work \
    && chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application

EXPOSE 8080
USER 1001

ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]

Dockerfile.jvm:

FROM registry.access.redhat.com/ubi8/openjdk-17:1.17

ENV LANGUAGE='en_US:en'


# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/

EXPOSE 8080
USER 185
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]

Solution

  • I solved my problem. The problem was, that some files where not in the src path. Now it works fine.