我正在尝试使用我的环境设置 https://spring.io/guides/gs/spring-boot-docker/#initial,该环境具有私有注册表服务器@
el-qa-docker.x.x.x:18445
My build.gradle 有以下相关内容:
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.3.RELEASE")
classpath('se.transmode.gradle:gradle-docker:1.2')
classpath ('org.codehaus.groovy:groovy-backports-compat23:2.3.5')
}
group = 'james'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'docker'
task buildDocker(type: Docker, dependsOn: build) {
push = true
applicationName = jar.baseName
dockerfile = file('src/main/docker/Dockerfile')
doFirst {
copy {
from jar
into stageDir
}
}
}
当我跑步时:$gradle build buildDock
我得到构建失败,与:
$ gradle build buildDock
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
:buildDocker FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildDocker'.
> Docker execution failed
Command line [docker build -t skahmed/gs-spring-boot-docker:latest /Users/skahmed/devops/TOOLS/DOCKER/gs-spring-boot-docker/initial/build/docker] returned:
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 16.243 secs
任何想法,关于我在哪里指定可以与 Gradle 一起使用的 docker 内部注册表。
我试过了:
docker {
useApi true
hostUrl 'el-qa-docker.x.x.x:18445'
apiUsername 'james'
}
由 https://github.com/Transmode/gradle-docker 提供
但这给出了一个不同的错误:
$ gradle build buildDock
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
:buildDocker FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildDocker'.
> Port is invalid: -1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.389 secs
我试过:build.gradle
docker {
//useApi true
hostUrl 'el2-dt-docker.uscis.dhs.gov:18445'
apiUsername 'skahmed'
}
和
task buildDocker(type: Docker, dependsOn: build) {
push = true
applicationName = jar.baseName
//applicationName = 'el2-dt-docker.uscis.dhs.gov:18445/skahmed/gs-spring-boot-docker'
//applicationName = 'gs-spring-boot-docker'
dockerfile = file('src/main/docker/Dockerfile')
doFirst {
copy {
from jar
into stageDir
}
}
}
但得到:
:buildDocker FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildDocker'.
> Docker execution failed
Command line [docker push skahmed/gs-spring-boot-docker:latest] returned:
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
您可以将私有 Docker 注册表指定为 Docker 映像名称的一部分,例如:
el-qa-docker.x.x.x:18445/skahmed/gs-spring-boot-docker
请确保您的 Docker 守护程序知道私有注册表。