This article is a part of my course project about Cloud Native. You can access the report’s full text from here.
Situation
When finishing my course project about Cloud Native, I tried to use Jenkins to build a docker image and push it to my harbor. At the same time, my Jenkins is running in a docker container. Hence, I needed to run docker in a dockerized Jenkins container.
According to the solution in Docker Community Forums, I can try to use the docker.sock of the host machine to run docker in a dockerized Jenkins container. Just run the following command when running the Jenkins container:
docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker)
Or I used the docker-compose to run the Jenkins container:
-/usr/bin/docker:/usr/bin/docker
- /var/run/docker.sock:/var/run/docker.sock
- /etc/docker/daemon.json:/etc/docker/daemon.json
Then, the dockerized Jenkins container can run docker commands successfully. However, when I tried to build a docker image, I got the following error:
docker: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.32' not found (required by docker)
Analysis
The error message shows that the GLIBC version is not compatible with the docker version. After checking I found that the GLIBC version in Jenkins container is older than the 2.32 version.
So at this time, I need to update the GLIBC version in the Jenkins container, or I can use the docker in the older version.
However, because Jenkins just runs in a docker container, so it’s hard to update the GLIBC version in the Jenkins container, as it lacks most of the tools. So I decided to use the older version of docker.
Solution
After checking docker in different versions, I found that only the docker version older than 20.10.12 doesn’t need the GLIBC 2.32 version. So I just need to downgrade the docker version can solve this problem.
Attention: If you want to downgrade the docker version, you need to remove the docker first. So it’s necessary to use docker-compose or docker -v to map the data into the data volume. Otherwise, you will lose all the data in the docker.