Reputation: 518
I am following this tutorial to build a hello-world maven java app with jenkins in dockers: https://jenkins.io/doc/tutorials/building-a-java-app-with-maven/#fork-and-clone-the-sample-repository-on-github
This is my app (just fork form the tutorial): simple-java-maven-app
It has a small difference that I used remote repo (Github) not a local repo (or host repo) in Pipeline's option (Repository URL). I pushed Jenkinsfile to repo then build hello-world app with Pipeline.
// Jenkinsfile for Pipeline
pipeline {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
}
}
}
}
I got this error below and can not find any solution for it. I using Windows 10.
docker pull maven:3-alpine
Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
Thanks everyone.
Upvotes: 2
Views: 5621
Reputation: 2687
You are using Docker in Docker (DinD) which is not a recommended CI approach. You should mount your Host's Docker Daemon Socket as volume to the Jenkins container like:
docker container run -v /var/run/docker.sock:/var/run/docker.sock ...
So you can work with images & containers on your host machine rather than in the Jenkins container. Click Here to learn more.
Upvotes: 4