SoFunction
Updated on 2025-03-09

Detailed explanation of the docker image instance building jenkins

Detailed explanation of the docker image instance building jenkins

Preface: jenkins has a Docker image, and we said before that we use jenkins to package Docker image. So can we use jenkins' Docker image to package Docker image?

environment:

    CentOS 7
    Docker 1.10.3

1. Install the docker environment on this machine and configure the TCP access interface

  # vi /usr/lib/systemd/system/

Modify ExecStart to:

  ExecStart=/usr/bin/docker daemon --tls=false -H unix:///var/run/ -H tcp://0.0.0.0:2375

2. Pull and run the docker image of jenkins

 # docker pull /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. Install plug-in: CloudBees Docker Build and Publish plug

4. Configure the docker inside the jenkins image. Here we directly use the binary compiled version of docker:

 # wget /builds/Linux/x86_64/docker-latest
  # mv docker-latest /usr/bin/docker
  #chomd +x /usr/bin/docker

5. Create apache project, select git for source code management, and the URL is:/lightingLYG/

Add the build pace, select "Docker Build and Publish", fill in the name, and the Docker Host URI is tcp://host host:2375

Then click Advanced and select "Skip Push"

You can build it after saving. The push to the server is skipped here.

6. Go to the host to check whether the image is packaged

  # docker images

Thank you for reading, I hope it can help you. Thank you for your support for this site!