Linux环境 Ubuntu 22.04
docker 最新版
jenkins docker 版本(以下版本都会报错
jenkins/jenkins:centos7
jenkins/jenkins:lts-centos7
jenkins/jenkins:lts
docker-compose.yml配置
version: '3.6'
services:gitlab:image: twang2218/gitlab-ce-zhrestart: alwayscontainer_name: gitlabhostname: '192.168.2.128'environment:TZ: 'Asia/Shanghai'GITLAB_OMNIBUS_CONFIG: |external_url 'http://192.168.2.128'gitlab_rails['time_zone'] = 'Asia/Shanghai'
# 需要配置到 gitlab.rb 中的配置可以在这里配置,每个配置一行,注意缩进。
# 比如下面的电子邮件的配置:
# gitlab_rails['smtp_enable'] = true
# gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
# gitlab_rails['smtp_port'] = 465
# gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
# gitlab_rails['smtp_password'] = "password"
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['smtp_tls'] = true
# gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'ports:- '80:80'- '443:443'- '2222:22'volumes:- ./gitlab/config:/etc/gitlab- ./gitlab/data:/var/opt/gitlab- ./gitlab/logs:/var/log/gitlabnetworks:- CI/CDjenkins:image: jenkins/jenkins:lts #镜像名称container_name: jenkins #指定容器名restart: always #在容器退出时总是重启容器user: root #指定用户ports: #容器的端口映射到宿主机上(“:”前数字为宿主机端口,“:”后数字为容器端口)- "8080:8080" #自定义宿主机端口8080- "5000:5000"environment:TZ: Asia/Shanghai #指定容器运行所属时区volumes:- ./jenkins/jenkins_home:/var/jenkins_home- ./jenkins/home:/home #将容器的/home目录映射到宿主机上目录中的/data/jenkins/home子目录- /etc/localtime:/etc/localtime- /var/run/docker.sock:/var/run/docker.sock #Docker守护进程(Docker daemon)默认监听的Unix域套接字(Unix domain socket),容器中的进程可以通过它与Docker守护进程进行通信。简单来说容器使用宿主机docker命令- /usr/libexec/docker/cli-plugins/docker-compose:/usr/local/bin/docker-compose- /usr/bin/docker:/usr/bin/docker
# - /lib/x86_64-linux-gnu/libc.so.6:/lib/x86_64-linux-gnu/libc.so.6networks:- CI/CD
networks:CI/CD:driver: bridge
报错信息
18:38:38 $ docker-compose -f /var/jenkins_home/workspace/test-springboot/docker-compose.yml up -d
18:38:38 Building test-java
18:38:38 docker: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by docker)
18:38:38 docker: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by docker)
18:38:38 Service 'test-java' failed to build : Build failed
18:38:38 Build step 'Docker Compose Build Step' changed build result to FAILURE
18:38:38 ERROR: Failed to parse POMs
18:38:38 java.io.EOFException: unexpected stream termination
18:38:38 at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:459)
18:38:38 at hudson.remoting.ChannelBuilder.build(ChannelBuilder.java:404)
18:38:38 at hudson.slaves.Channels.forProcess(Channels.java:121)
18:38:38 at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:298)
18:38:38 at hudson.maven.ProcessCache.get(ProcessCache.java:237)
18:38:38 at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:802)
18:38:38 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:526)
18:38:38 at hudson.model.Run.execute(Run.java:1895)
18:38:38 at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
18:38:38 at hudson.model.ResourceController.execute(ResourceController.java:101)
18:38:38 at hudson.model.Executor.run(Executor.java:442)
18:38:38 Finished: FAILURE
解决方法:
替换 jenkins docker版本
改为 jenkins/jenkins:jdk11
原因
可能是因为报错的底层镜像用的都是centos,与ubuntu22.04不兼容,
ubuntu22.04应该使用jenkins/jenkins:jdk11 ,他的From镜像是eclipse-temurin:“${JAVA_VERSION}”-jdk-focal,
然后在上级的From镜像应该是ubuntu:20.04,所有才能兼容使用
代码示例
https://gitee.com/xiaoyun461/git-lab-docker.git