Using the Gradle Docker plugin , I am trying to build a Docker image with a Dockerfile I already created. I got this far
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
}
I am getting this error though
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
In the end I used the command line to do the build, here's my build.gradle
file where I commented out the plugin code. It solves my immediate problem for the builds, but it is more ideal than exposing 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
}
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.