Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use docker to build a jenkins image and run the container

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use docker to build a jenkins image and run the container". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use docker to build a jenkins image and run a container".

Table of contents:

1. Launch the container based on the official jenkins image of docker

2. Use the source code to build the jenkins image and run the container

3. Use csphere products to manage containers, images and hosts

Docker has been very popular in the past two years and recently listened to the docker training sponsored by cSphere Xiyun.

I have previously participated in docker-related technology salons (such as docker meetup).

I've also been using Jenkins for nearly two years, so try to use docker to build jenkins images and run image-based containers.

I got a 200 yuan Tencent Cloud voucher for listening to Xiyun's docker training.

So I used the voucher to buy a CVM on Tencent Cloud for docker exercises.

Naturally, the system type is selected: cSphere Free Edition (Ubuntu), in order to experience the products of cSphere.

There is an official docker jenkins image on DockerHub: https://registry.hub.docker.com/_/jenkins/

At the same time, there is a source code on github: https://github.com/jenkinsci/docker

The jenkins used in the official jenkins image is the LTS (Long Term Support) release version of Jenkins.

1. Launch the container based on the official jenkins image of docker

Run the command as follows: docker run-- name myjenkins-p 8080pur808080v / var/ jenkins_home jenkins

Docker run-- name myjenkins-p 8080VR 8080-v / var/jenkins_home jenkins

When you run the docker run command, if there is no mirror locally, it will cache the image locally from the DockerHub pull image by default, and then start the container created based on the image.

Use docker images to view image information:

Use docker ps to view the running container information:

Access jenkins through the web interface:

2. Use the source code to build the jenkins image and run the container

Use the git clone source code locally:

Git clone https://github.com/jenkinsci/docker.git

Change to the docker directory and use the docker build command to build the image:

Cd docker

Use docker build+Dockerfile to build a jenkins image:

Docker build-t donhui/jenkins.

After the image is successfully built (a total of 21 Step,Dockerfile and 21 instructions), use docker images to view the image

The donhui/jenkins image is the same size as the official jenkins image:

Use docker ps to view the running container information:

Use docker stop 71150c3aabc6 to stop containers started based on the official jenkins image before:

Start the container based on donhui/jenkins image

Docker run-- name donhui_jenkins-p 8080VR 8080-v / var/jenkins_home donhui/jenkins

Use docker ps to view the running container information:

Access jenkins through the web interface:

3. Use csphere products to manage containers, images and hosts

View container donhui_jenkins information:

View image donhui/jenkins:latest information:

Thank you for reading, the above is the content of "how to use docker to build jenkins image and run container". After the study of this article, I believe you have a deeper understanding of how to use docker to build jenkins image and run container, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report