[英]In Docker.DotNet how do you build an image by specifying the directory of the Dockerfile?
[英]How do you use the Gradle Docker Plugin to build a docker image with a provided Dockerfile in Windows?
使用Gradle Docker 插件,我正在嘗試構建一個 Docker 圖像,其中已經創建了 Z3254677A7217C6C01F555C11。 我走到這一步
plugins {
id 'com.bmuschko.docker-remote-api' version '6.4.0'
}
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.DockerPushImage
task dockerBuildImage(type: DockerBuildImage) {
inputDir = projectDir
images.add('trajano/cloud-auth')
}
task dockerPushImage(type: DockerPushImage) {
dependsOn dockerBuildImage
images.add('trajano/cloud-auth')
}
task build {
dependsOn tasks.dockerPushImage
}
雖然我收到了這個錯誤
Building image using context 'D:\p\spring-cloud-demo\cloud-auth'.
Using images 'trajano/cloud-auth'.
Error during callback
com.bmuschko.gradle.docker.shaded.org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:2375 [/127.0.0.1] failed: Connection refused: connect
最后我使用命令行進行構建,這是我的build.gradle
文件,我在其中注釋掉了插件代碼。 它解決了我對構建的直接問題,但它比暴露 2375 更理想。
plugins {
// id 'com.bmuschko.docker-remote-api' version '6.4.0'
}
//import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
//import com.bmuschko.gradle.docker.tasks.image.DockerPushImage
task dockerBuildImage(type: Exec) {
// inputDir = projectDir
// images.add('trajano/cloud-auth')
commandLine "docker", "build", ".", "-t", "trajano/cloud-auth"
}
task dockerPushImage(type: Exec) {
dependsOn dockerBuildImage
commandLine "docker", "push", "trajano/cloud-auth"
}
task build {
dependsOn tasks.dockerPushImage
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.