Jenkins in a Docker container (docker pipeline works)

I want to run Jenkins in a Docker container. Everything is good. I can run it like this: docker run -d --name jenkins -t -i -p 49001:8080 jenkins I can also add persistent storage. The problem arose when I created the pipeline, it can execute docker commands ( build and push ). Firstly, the error was that the docker was not installed in the system. Yes, it was expected. Then I started the search and found out how I can run docker in the container (passing 2 permanent volumes): docker run ... -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker -p 49001:8080 jenkins

This is true, but with a few exceptions. There is a docker in the container, but when I try to run it, it throws an exception: docker: error while loading shared libraries: libltdl.so.7: cannot open shared object file: No such file or directory

How can I fix this problem? What is the correct way to install Jenkins in Docker and run Docker? I think there are two ways:

  • The one I do - use sockets
  • I can open a docker api that allows you to connect and run commands

Is Dankins really worth playing docker? I tried installing the missing lib library manually from apt-get This works, but I know that this is not the right way.

+5
source share
1 answer

You need to install libltdl-dev for everything to work correctly. Create a Dockerfile that looks like this:

 FROM jenkins:latest USER root RUN apt-get update \ && apt-get upgrade -y \ && apt-get install -y sudo libltdl-dev \ && rm -rf /var/lib/apt/lists/* RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers USER jenkins # Here you can install some Jenkins plugins if you want 
+6
source

Source: https://habr.com/ru/post/1269856/


All Articles