I have configured a private docker registry without any authentication on a local virtual machine. On the same vm server I have jenkins running.
I am trying to create jenkins pipeline for my spring boot maven project to build and push a docker image to a private docker registry.
My spring boot maven plugin configuration in pom.xml looks like below
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name><vm-name>:5000/dev/my-spring-boot-app:v1</name>
<publish>true</publish>
</image>
<docker>
<publishRegistry>
<url>http://<vm-name>:5000</url>
</publishRegistry>
</docker>
</configuration>
</plugin>
My Jenkinsfile looks like below
pipeline {
agent {
docker {
image 'maven:3.8.1-adoptopenjdk-11'
args '-v /root/.m2:/root/.m2 -v "$pwd":/usr/src/app -w /usr/src/app'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
}
}
stage('Build Docker image') {
steps {
echo "Build Docker Image"
sh "mvn -DskipTests spring-boot:build-image"
}
}
}
When this pipeline executes on the jenkins server I get the below error
[INFO] --- spring-boot-maven-plugin:2.5.2:build-image (default-cli) @ prototype-be ---
[INFO] Building image '<vm-name>:5000/dev/my-spring-boot-app:v1'
[INFO]
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
Could someone guide me on how my jenkins file should be to build and push the docker image?
Thanks.