8

Jenkins job fails when entering docker build stage:

docker build -t jumperiz/nodeapp .

Error message:

docker: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by docker)
docker: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by docker)

A picture of my build attached. Any guidance would be appreciated!


Jenkins screenshot

mirekphd
  • 4,799
  • 3
  • 38
  • 59
Sadok Bouzrati
  • 93
  • 1
  • 1
  • 4
  • A screenshot of a Jenkins build showing a failure doesn't really help clarify the issue at all. What is in your Jenkins pipeline code? Is it a problem with the pipeline, or a system-administration question of getting Docker correctly installed in Jenkins? Speculating wildly, are you running Jenkins in a container and bind-mounting the host's Docker binary into it; [Docker not found when building docker image using Docker Jenkins container pipeline](https://stackoverflow.com/questions/44850565/docker-not-found-when-building-docker-image-using-docker-jenkins-container-pipel) might help? – David Maze Jul 25 '22 at 13:54
  • yes i am running jenkins in a container instance and mounting the host's docker binary into it here is my docker run command : docker run -u 0 --privileged --name -it -d -p 8080:8080 -p 50000:50000 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v $(which docker) :/usr/bin/docker \ -v /home/jenkins_home: /var/jenkins_home \ jenkins/jenkins:latest – Sadok Bouzrati Jul 25 '22 at 15:05
  • when i do a docker run -it -u root /bin/bash and log into my container and when i try to check dockers version the result is => GLIBC_2.32' not found (required by docker) docker: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.34' not found (required by docker) a picture of my build is attached. – Sadok Bouzrati Jul 25 '22 at 15:22
  • 1
    The `-v $(which docker):/usr/bin/docker` won't work reliably. Install the Docker CLI tool in your Jenkins Dockerfile. – David Maze Jul 25 '22 at 15:36
  • should i add it in the pipeline ?if you have any documentation for that please that would help i am a beginner and tryin to do my first Devops project – Sadok Bouzrati Jul 25 '22 at 15:59
  • 1
    the proble that i have glibc 2.31 in the container and i need to upgrade it to 2.32 docker requires that version any suggestions please ? – Sadok Bouzrati Jul 25 '22 at 21:14
  • It requires 2.32 and 2.34. `yum update` your host os. – Ian W Jul 25 '22 at 22:28

4 Answers4

9

You need to install docker manually and you can follow this steps:

  • run jenkins container on detached mode:
    docker run -p 8080:8080 -p 50000:50000 -d -v /var/run/docker.sock:/var/run/docker.sock -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
    
  • Enter the jenkins container as root user:
    docker exec -it -u0 <container id> bash
    
  • Install docker:
    curl https://get.docker.com > dockerinstall && chmod 777 dockerinstall && ./dockerinstall
    
  • And then exit the Jenkins container and change docker.sock privilege to read and write for all users with:
    sudo chmod 666 /var/run/docker.sock
    
Ali
  • 922
  • 1
  • 9
  • 24
3

I had the same problem, as described in detail here.

To upgrade libc version in the Jenkins container to 2.35 (as shipped with Ubuntu Jammy installed on the host) I had to build my own Jenkins container based on this system (ubuntu:jammy) and on JDK 17, using template from the official Debian-based one (sourced from here).

Now GLIBC versions agree, and Docker-in-Docker Jenkins builds can be made using Docker installed on any host with Ubuntu Jammy (but not newer Ubuntu versions, given that next in line, ubuntu:22.10 already has a newer version of glibc=2.36):

$ ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35

# vs.

$ docker run --rm -it mirekphd/jenkins-jdk17-on-ubuntu2204:latest ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35

Feel free to use this container maintained automatically for our internal use (it's a Docker-in-Docker Jenkins-made-by-Jenkins pipeline:)

mirekphd
  • 4,799
  • 3
  • 38
  • 59
3

I've encountered the same problem.

This can happen when you mount the host's docker binary, which relies on a different glibc version than the one in your Jenkins image.

To resolve this issue, I found the two following solutions:

You could build a custom Jenkins image based on the official template, using ubuntu:jammy instead of Debian. However, note that this approach has some drawbacks. Specifically, any sibling docker containers created by Jenkins will also need to have glibc 2.35, which means you'll need to modify and build those images yourself using jammy buildpack-deps.

Alternatively, you could install docker inside the Dockerfile instead of mounting the host's docker binary. This will enable Jenkins to use its own docker client and communicate with the docker engine using only the mounted docker socket. This approach is generally better since it ensures that Jenkins uses its own docker client, avoiding any dependency conflicts with the host's docker binary.

MilmanRon
  • 31
  • 2
  • 1
    Thanks, I had a similar issue when I rebuilt my docker image, it got new version of glibc, but my /usr/bin/docker was mounted from the host where glibc was old, so this caused the error. – grihabor Apr 18 '23 at 17:17
1

I solved this issue using these steps

Issue:

root@81d156e97b9c:/# docker -v
docker: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by docker)
docker: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by docker)

First of all

  • build image from docker file: this is Docker file content for record

FROM jenkins/jenkins:lts
USER root
RUN apt-get update && \
    apt-get -y install apt-transport-https \
         ca-certificates curl gnupg2 \
         software-properties-common && \
    curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
    add-apt-repository \
      "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
      $(lsb_release -cs) \
      stable" && \
    apt-get update && \
    apt-get -y install docker-ce
USER jenkins

using this command

docker build -t custom-jenkins-docker:v1 .
image size was 1.04Gb in my case (for knowledge)

then run this command to make container of that image

docker run -p 8080:8080 -p 50000:50000 -d -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock custom-jenkins-docker:v1

Know the CONTAINER ID

docker ps

after that enter exec mode in bash shell as root user

docker exec -u 0 -it 557c4a24ff3f bash

Now you can use docker commands

But What if I want to access docker using normal user?

then we have to change permissions of docker.sock file to 666 instead of 660 in host machine

sudo chmod 666 /var/run/docker.sock

run this command inside container

docker exec -it 557c4a24ff3f bash

Now you can use Docker as Normal user