3

I am trying to configure Jenkins as docker container with docker-in-docker on an EC2 instance running Ubuntu 22.04 but I am getting `GLIBC_2.32' and 'GLIBC_2.34' not found when I try to run a script containing docker command using docker plugin in Jenkins. I have followed this as reference for setting Jenkins on my localhost. When moved to remote, I get these errors

...
$ docker login -u username -p ******** https://registry.gitlab.com
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)
...

Here is the docker-compose.yaml file

version: '3.3'

services:
  docker-in-docker-container:
    image: docker:dind
    container_name: docker-in-docker-container
    user: root
    privileged: true
    expose:
      - 2375
    volumes:
      - ./data:/var/jenkins_home
    environment:
      DOCKER_TLS_CERTDIR: ""
    restart: on-failure

  jenkins-container: 
    image: jenkins/jenkins:lts-jdk17
    container_name: jenkins-container
    user: root
    depends_on:
      - docker-in-docker-container
    ports:
      - '8080:8080'
    privileged: true
    volumes:
      - ./data:/var/jenkins_home
      - /usr/bin/docker:/usr/bin/docker
    environment:
      DOCKER_HOST: tcp://docker-in-docker-container:2375
    restart: on-failure

I tried to use various images from the Jenkins docker repository like alpine, jdk8, jdk11, and jdk17, but no luck.

Here is ldd info for troubleshooting from host machine

ubuntu@ip-10-0-0-251:~$ ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3) 2.35
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Here is ldd info for Jenkins container

root@a2da70fc6100:/# ldd --version
ldd (Debian GLIBC 2.31-13+deb11u3) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Looking forward to any help! Thanks.

Izhar Hussain
  • 33
  • 1
  • 1
  • 4

3 Answers3

4

Try UBUNTU 18.04LTS IT WILL WORK

Same error I got in Ubuntu 22.04lts on my Ec2 instance where I am trying to integrate docker to Jenkins container using docker runtime docker.sock by following command

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

docker exec -it -u 0 <container-id> bash

chmod 666 /var/run/docker.sock

It will allow docker runtime to integrate with jenkins

Tried docker pull

It threw me the same error

Getting 'GLIBC_2.32' and 'GLIBC_2.34' not found in Jenkins ( required by Docker)

The reason is Ec2 instance of Ubuntu 22.04lts has GLIBC 2.35

check this command in ece instance

ldd --version

But inside instance jenkins container has GLIBC 2.31 CHECK

ldd --version GLIBC 2.31

SO BECAUSE OF THIS DOCKER won't work inside that jenkins container in Ubuntu 22.04lts

Then I TRIED IN Ubuntu 18.04 LTS Use the same steps again

docker run -d -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker -v $(which docker):/usr/bin/dock jenkins/jenkins:lts

docker exec -it -u 0 <container-id> bash

chmod 666 /var/run/docker.sock

Now check docker pull...

It worked perfectly

trxgnyp1
  • 317
  • 1
  • 10
  • Another option would be to delete -v $(which docker):/usr/bin/docker and install the correct docker version inside the container. – jinawee Aug 26 '22 at 14:34
2

As you're suspecting, you've having shared-library issues because you're injecting a docker binary that depends on a different version of GNU libc than exists in the image.

Injecting a docker binary like this isn't especially reliable due to issues like this. In theory you could work around it by building a custom image that installed the required versions of the shared libraries, but if you're doing that, it's easier and safer to install the docker CLI tool in the image. (Running the Docker daemon has complex requirements, but the CLI tool itself doesn't depend on anything other than access to a Docker socket.) Also see the "Installing more tools" section in the Jenkins image documentation.

FROM jenkins/jenkins:lts-jdk17
USER root
RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive \
    apt-get install --no-install-recommends --assume-yes \
      docker.io
USER jenkins

You do not need EXPOSE, CMD, or other setup; that all comes from the base image.

In the Compose file, add a build: line to build this custom image, delete the image: line, and delete the volumes: mounting the host's /usr/bin/docker.

version: '3.8'
services:
  jenkins-container:
    build: .
    # no image:
    volumes:
      - ./data:/var/jenkins_home
      # but not /usr/bin/docker
David Maze
  • 130,717
  • 29
  • 175
  • 215
  • This doesn't start the demon the image is not writable. Need `service docker start` but i am getting a `mkdir: cannot create directory ‘cpuset’: Read-only file system` – user1634451 Sep 24 '22 at 01:32
0

use this dockerfile to install docker and dependencies

FROM jenkins/jenkins:lts
MAINTAINER madhusudan reddy
USER root
RUN apt-get -y update; apt-get install -y sudo; apt-get install -y git wget
RUN echo "Jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers
RUN wget http://get.docker.com/builds/Linux/x86_64/docker-latest.tgz
RUN tar -xvzf docker-latest.tgz
RUN mv docker/* /usr/bin/
USER Jenkins
madhu
  • 1,083
  • 3
  • 12
  • 31