[英]Not able to connect to docker image with a spring boot application
[英]docker image of spring boot application
我想了解如何使用 Gradle 创建 spring 启动应用程序的 docker 映像,因为它们是我商店的相同要求。
要开始,我已经提到了 https://spring.io/guides/gs/spring-boot-docker/
我按照这里提到的所有步骤进行操作。
我的 Dockerfile 如下所示
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
EXPOSE 8080
ENTRYPOINT ["java","-cp","app:app/lib/*","hello.Application"]
我的 build.gradle 是
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
}
}
group = 'springio'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.palantir.docker'
bootJar {
baseName = 'gs-spring-boot-docker'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
task unpack(type: Copy) {
dependsOn bootJar
from(zipTree(tasks.bootJar.outputs.files.singleFile))
into("build/dependency")
}
docker {
name "${project.group}/${bootJar.baseName}"
copySpec.from(tasks.unpack.outputs).into("dependency")
buildArgs(['DEPENDENCY': "dependency"])
}
但是当我毁了
$./gradlew build docker
低于错误
FAILURE: Build failed with an exception.
* Where:
Build file '/root/springboot-Dockerf/gs-spring-boot-docker/initial/build.gradle' line: 16
* What went wrong:
A problem occurred evaluating root project 'initial'.
> Plugin with id 'com.palantir.docker' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get
more log output. Run with --scan to get full insights.
尝试使用以下方式
plugins {
id "com.palantir.docker" version "0.22.1"
}
apply plugin: "com.palantir.git-version"
https://plugins.gradle.org/plugin/com.palantir.docker
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.