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

Bootstrap 3.0 study notes grid system case

Preface In the previous article, we mainly learne...

Detailed explanation of the use of Vue3 state management

Table of contents background Provide / Inject Ext...

Summary of some situations when Docker container disk is full

Preface This article describes two situations I h...

Image hover toggle button implemented with CSS3

Result:Implementation Code html <ul class=&quo...

How to allow external network access to mysql and modify mysql account password

The root account of mysql, I usually use localhos...

How to install mysql6 initialization installation password under centos7

1. Stop the database server first service mysqld ...

Introduction to CSS3 color value RGBA and gradient color usage

Before CSS3, gradient images could only be used a...

WeChat applet canvas implements signature function

In the WeChat applet project, the development mod...

JS implements request dispatcher

Table of contents Abstraction and reuse Serial Se...

Steps to install MySQL 5.7.10 on Windows server 2008 r2

Install using the MSI installation package Downlo...

Nginx Location directive URI matching rules detailed summary

1. Introduction The location instruction is the c...

Tips for viewing History records and adding timestamps in Linux

Tips for viewing History records and adding times...

Solve the problem of running hello-world after docker installation

Installed Docker V1.13.1 on centos7.3 using yum B...

Design Theory: Hierarchy in Design

<br />Original text: http://andymao.com/andy...

Learn MySQL in a simple way

Preface The database has always been my weak poin...