简体   繁体   中英

Build spring boot app docker image by gradle: ADD failed:

I want to create my docker image of my app by gradle:

build.gradle

task buildDocker (type:Docker, dependsOn: build) {
    applicationName = jar.baseName
    dockerfile = file('Dockerfile')
    doFirst {
        copy {
            from jar
            into stageDir
        }
    }
}

Dockerfile:

FROM openjdk:8-jdk-alpine

VOLUME /tmp

EXPOSE 8083

ADD build/libs/app-0.0.1-SNAPSHOT.jar app.jar

ENTRYPOINT ["java","-jar","/app.jar"]

But at the end of the execution I got this error:

BUILD FAILED in 28s
7 actionable tasks: 3 executed, 4 up-to-date
Docker execution failed
Command line [docker build -t com.project/app:0.0.1-SNAPSHOT /home/adrian/IdeaProjects/App/build/docker] returned:
ADD failed: stat /var/lib/docker/tmp/docker-builder669437080/build/libs/app-0.0.1-SNAPSHOT.jar: no such file or directory

11:22:34 AM: Task execution finished 'buildDocker'.

I tried a lot of thing - rename folders, change paths etc. anything doesnt look to work. And I dont understand why I got this error because this file: /build/libs/app-0.0.1-SNAPSHOT.jar exists.

目标字段中的用户绝对路径

ADD your_path/yourfile /app.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM