Some ways to solve the problem of Jenkins integrated docker plugin

Some ways to solve the problem of Jenkins integrated docker plugin

background

The test environment uses Jenkins integrated with the docker plug-in to implement a one-click deployment service for the test environment. First, Jenkins has installed the docker build and publish plug-in, but a series of problems have occurred in the operation of the job!

Question 1

Docker execution reports an error, Build step 'Docker Build and Publish' marked build as failure. There are many problems that lead to this sentence. More detailed error information: Jenkins container does not support docker operations?

Analysis of the problem: Jenkins is deployed using docker, so there are no docker-related operation commands in the Jenkins container, so the execution fails!

Solution: You need to map the host's Docker environment to the Jenkins container before you can use the Docker command line.

docker run --name myjenkins -p 8123:8080 -p 50000:50000 -v /run/docker.sock:/var/run/docker.sock -v /var/jenkins_home:/var/jenkins_home -u 0 -d jenkins/jenkins:lts

Execute again, the result is still wrong, no solution!

Error 2

It prompts that there is no executable command in the bin directory?

Analysis: We know that for any environment that we install, if we want to execute its command line in the Linux environment, we need to add the environment variable: /usr/bin

Solution: Continue to map the host docker executable command

docker run --name myjenkins -p 8123:8080 -p 50000:50000 -v /run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker -v /var/jenkins_home:/var/jenkins_home -u 0 -d jenkins/jenkins:lts

Tips: The which command is similar to whereis to find commands or files: the former checks the commands in the system environment variables (returns the first result), and the latter returns the path related to the program name (returns all matching results)

Error 3

Unable to find related dependencies: error while loading shared libraries: libltdl.so.7: cannot open shared object file: No such file or/libltdl.so.7

Analysis: Inside the jenkins container, because the container is not shared with the host, the library can be found on the host: cd usr/lib64/

Solution: Find the libltdl.so.7 dependency library on the host and mount the container

docker run --name myjenkins -p 8123:8080 -p 50000:50000 -v /run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker -v /usr/lib64/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7 -v /var/jenkins_home:/var/jenkins_home -v /var/data/shell:/var/data/shell -u 0 -d jenkins/jenkins:lts

Error 4

no basic auth credentials No authentication

Analysis of the cause: This plug-in uses the docker command inside the jenkins container. There is no error in building the image. When it needs to be pushed to the image repository in the container, auth is required.

Solution: Directly add a line of authentication to the Jenkins job, docker login --username=xxxx --password=xxxx nexus.xxxx.com

Tips: After executing the command, a .credentials will be generated in the current directory, which records the account and password information for logging in to the nexus image repository

Summarize

At this point, the previous steps have been completed and docker commands can be used inside the jenkins container. There is no need to use the shh plug-in to jump out of the container to the host to execute the build & push operation commands. You only need to execute the script to start the container!

In Docker containerization, everything mapped between the host and the container is the same, that is, whether the file mounted on the host in the container is modified or the mounted host file is modified in the container, both will be modified at the same time.

This is the end of this article about some methods to solve the problem of Jenkins integrated docker plug-in. For more relevant Jenkins integrated docker plug-in content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Implementation of Jenkins+Docker continuous integration
  • Detailed tutorial on building a continuous integration delivery environment based on Docker+K8S+GitLab/SVN+Jenkins+Harbor
  • A complete example of continuous integration with ASP.NET Core+Docker+Jenkins

<<:  A new CSS image replacement technique (background display and text moving off screen) to say goodbye to 9999px

>>:  JavaScript implements the detailed process of stack structure

Recommend

How to install grafana and add influxdb monitoring under Linux

Install grafana. The official website provides an...

Mysql sql slow query monitoring script code example

1. Modify my.cnf #The overall effect is that both...

Markup Languages ​​- What to learn after learning HTML?

Click here to return to the 123WORDPRESS.COM HTML ...

What is the function and writing order of the a tag pseudo class

The role of the a tag pseudo-class: ":link&qu...

vue3.0+echarts realizes three-dimensional column chart

Preface: Vue3.0 implements echarts three-dimensio...

Website Design Experience Summary of Common Mistakes in Website Construction

Reminder: Whether it is planning, designing, or de...

CSS3 animation to achieve the effect of streamer button

In the process of learning CSS3, I found that man...

A detailed tutorial on how to install Jenkins on Docker for beginners

Jenkins is an open source software project. It is...

Learning about UDP in Linux

Table of contents 1. Introduction to UDP and Linu...

vue.js Router nested routes

Preface: Sometimes in a route, the main part is t...

Complete list of CentOS7 firewall operation commands

Table of contents Install: 1. Basic use of firewa...

Analyze the usage and principles of Vue's provide and inject

First, let's talk about why we use provide/in...

Hide HTML elements through display or visibility

Sometimes we need to control whether HTML elements...