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.
CodePudding user response:
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