Detail of jenkins building Docker image instance
- 2020-06-12 11:33:34
- OfStack
jenkins building Docker image example details
Foreword: jenkins has Docker image, and we said before that jenkins is used to package Docker image, can we package Docker image with Docker image?
Environment:
CentOS 7
Docker 1.10.3
1. Install docker environment and configure TCP access interface
# vi /usr/lib/systemd/system/docker.service
Modify ExecStart to:
ExecStart=/usr/bin/docker daemon --tls=false -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
2. pull and run the docker image of jenkins
# docker pull index.docker.io/library/jenkins:1.642.2
# docker run -d -e "DOCKER_HOST=tcp://192.168.10.136:2376" --name myjenkins -u root -p 8080:8080 -p 50000:50000 -v /home/jenkins-home-docker:/var/jenkins_home jenkins
docker cp /usr/bin/docker myjenkins:/usr/bin
3. Installation plug-ins: CloudBees Docker Build and Publish plug
4. Configure docker inside jenkins image. Here, we directly use the 2-base compiled version of docker:
# wget https://get.docker.com/builds/Linux/x86_64/docker-latest
# mv docker-latest /usr/bin/docker
#chomd +x /usr/bin/docker
5, create project apache, choose git source management, URL: https: / / git coding. net/lightingLYG/apache git
To add the build step, select "Docker Build and Publish" and fill in name, Docker Host URI is tcp:// Host host:2375
And then I'm gonna go to advanced and select "Skip Push"
Save and build, skipping push to the server
6. Go to the host to see if the image is packaged
# docker images
Thank you for reading, I hope to help you, thank you for your support to this site!