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

Summary of how to use the MySQL authorization command grant

How to use the MySQL authorization command grant:...

How to add configuration options to Discuz! Forum

Discuz! Forum has many configuration options in th...

How to limit the number of records in a table in MySQL

Table of contents 1. Trigger Solution 2. Partitio...

v-for directive in vue completes list rendering

Table of contents 1. List traversal 2. The role o...

How to build a DHCP server in Linux

Table of contents 1. Basic knowledge: 2. DHCP ser...

Nginx configures the same domain name to support both http and https access

Nginx is configured with the same domain name, wh...

How to use boost.python to call c++ dynamic library in linux

Preface Recently I started using robot framework ...

Mini Program implements custom multi-level single-select and multiple-select

This article shares the specific code for impleme...

A collection of common uses of HTML meta tags

What is a mata tag The <meta> element provi...

How to run tomcat source code in maven mode

Preface Recently, I was analyzing the startup pro...

How to check if a table exists in MySQL and then delete it in batches

1. I searched for a long time on the Internet but...

MySQL 5.7 zip archive version installation tutorial

This article shares the installation tutorial of ...

React method of displaying data in pages

Table of contents Parent component listBox List c...

WeChat applet realizes the nine-square grid effect

This article shares the specific code for the WeC...

View the dependent libraries of so or executable programs under linux

View the dependent libraries of so or executable ...