gpt4 book ai didi

docker - 使用Intellij在Spring Boot中使用Gradle构建Docker镜像

转载 作者:行者123 更新时间:2023-12-02 19:06:53 26 4
gpt4 key购买 nike

我有以下dockerfile。

FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

这是build.gradle。
buildscript {
ext {
springBootVersion = '2.0.0.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('se.transmode.gradle:gradle-docker:1.2')
}
}

apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'docker'



bootJar {
baseName = 'gs-spring-boot-docker'
version = '0.1.0'
}


group = 'com.pai'
version = '0.0.1-SNAPSHOT'

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

repositories {
mavenCentral()
}


dependencies {
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'mysql:mysql-connector-java'
compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}

build.gradle的进程同步成功。
当我运行以下命令时。
sudo ./gradlew build buildDocker

我收到以下错误消息。
Execution failed for task ':buildDocker'.
> Docker execution failed
Command line [docker push com.pai/pai201808:0.0.1-SNAPSHOT] returned:
Get https://com.pai/v2/: dial tcp: lookup com.pai on 127.0.1.1:53: no such host

我认为这可能是导入错误或配置的dockerfile无效的问题。我怎么解决这个问题?

最佳答案

Gradle脚本尝试将Docker镜像推送到不存在的存储库。您打算这样做吗?如果不是,则只需设置push = false

如果要将图像推送到某个存储库,则必须对其进行设置。您必须检查将镜像推送到所需存储库的特定于插件的设置。

更多信息:
Creating new repository on Docker HubSetting up own registry

关于docker - 使用Intellij在Spring Boot中使用Gradle构建Docker镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49333993/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com