首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Docker中的Docker/Podman作为GitLab CI工作失败

Docker中的Docker/Podman作为GitLab CI工作失败
EN

Server Fault用户
提问于 2021-11-01 05:50:02
回答 1查看 1.1K关注 0票数 3

上下文

我使用额外的CI服务器运行我自己的GitLab实例。如果这关系到我的主机,gitlab运行程序有CentOS 8,gitlab运行程序是14.4.0版本,gitlab实例运行14.4.1。我目前正在CI服务器上使用shell执行器,但希望切换到停靠器执行器。

Gitlab运行程序Config

我的/etc/gitlab-runner/config.toml看起来是这样的:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "the old shell executor"
  url = "https://XXXXXXXXXXXXXXXXXXXXXX/"
  token = "XXXXXXXXXXXXXXXXXXXX"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

[[runners]]
  name = "the new docker executor"
  url = "https://XXXXXXXXXXXXXXXXXXXXXX/"
  token = "XXXXXXXXXXXXXXXXXXXX"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker.io/centos:7"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    network_mode = "host"
    shm_size = 0

外壳执行器被标记为shell,而停靠器执行器是标记docker,这样我就可以从gitlab-ci.yml文件中决定在哪里运行构建。

gitlab-ci.yml

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
.template:
  before_script:
    - cat /proc/sys/user/max_user_namespaces
  script:
    - $ENGINE login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - $ENGINE build -f container/php-71.dockerfile -t "$CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/$TAG:$CI_PIPELINE_ID" .
    - $ENGINE push "$CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/$TAG:$CI_PIPELINE_ID"

build-with-docker-in-shell-executor:
  extends: .template
  variables:
    ENGINE: docker
    TAG: build-with-docker
  tags: [shell]
build-with-docker-in-docker-executor:
  extends: .template
  image: docker:dind
  variables:
    ENGINE: docker
    TAG: build-with-docker-in-docker
  tags: [docker]
build-with-podman-in-docker-executor:
  extends: .template
  image: quay.io/podman/stable
  variables:
    ENGINE: podman
    TAG: build-with-podman-in-docker
  tags: [docker]

我的container/php-71.dockerfile很简单,它使用centos:7并执行一系列yum install命令:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
FROM docker.io/centos:7
RUN yum install -y epel-release centos-release-scl
RUN yum install -y rh-php71

第一个作业失败,因为我的gitlab runner用户无法访问坞套接字:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Got permission denied while trying to connect to the Docker
daemon socket at unix:///var/run/docker.sock: Post
"http://%2Fvar%2Frun%2Fdocker.sock/v1.24/auth": dial unix
/var/run/docker.sock: connect: permission denied

我认为这是可以的(或者现在是否应该授予非根用户对docker的访问权?)。所以这份工作只是供参考之用。

由于yum没有网络访问权限,码头作业中的停靠者失败:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Step 1/3 : FROM docker.io/centos:7
 ---> eeb6ee3f44bd
Step 2/3 : RUN yum install -y epel-release centos-release-scl
 ---> Running in 8e41cd05bcc1
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container: (28, 'Resolving timed out after 30548 milliseconds')
 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:
     1. Contact the upstream for the repository and get them to fix the problem.
     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).
     3. Run the command with the repository temporarily disabled
            yum --disablerepo= ...
     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:
            yum-config-manager --disable 
        or
            subscription-manager repos --disable=
     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:
            yum-config-manager --save --setopt=.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
The command '/bin/sh -c yum install -y epel-release centos-release-scl' returned a non-zero code: 1

而坞中的podman是其中最奇怪的错误,它已经在podman login命令中失败了:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
time="2021-11-01T13:34:31Z" level=warning msg="\"/\" is not a shared mount, this could cause issues or missing mounts with rootless containers"
cannot clone: Operation not permitted
Error: cannot re-exec process

问题

我想使用泊人在码头或码头码头,以建立我的形象。我可以采取哪些步骤来调试和修复这个问题?

EN

回答 1

Server Fault用户

回答已采纳

发布于 2023-03-22 08:41:23

在某种程度上,我已经找到了卡尼科,现在正在用它构建容器。我的gitlab CI模板如下所示:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
.build-container-with-kaniko:

  stage: build-containers

  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]

  script:
    - mkdir -p /kaniko/.docker
    # this is needed to push the final image back to the container registry on gitlab
    - AUTH="$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')"
    - echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"${AUTH}\"}}}" > /kaniko/.docker/config.json
    - >-
      /kaniko/executor
      --context "${CI_PROJECT_DIR}"
      --dockerfile "${CI_PROJECT_DIR}/${DOCKERFILE}"
      --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CI_PIPELINE_ID}"
      --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CI_COMMIT_TAG:-latest}"
      ${EXTRA_ARGS}

  variables:
    DOCKERFILE: Dockerfile
    IMAGE_NAME: generic-image
    EXTRA_ARGS: ""

  tags:
    - docker

tags: [docker]意味着我在gitlab runner的码头执行器上运行这些作业。

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1082279

复制
相关文章
Gitlab CI 在 Kubernetes 中的 Docker 缓存
前面我们有文章介绍过如何在 Kubernetes 集群中使用 GitLab CI 来实现 CI/CD,在构建镜像的环节我们基本上都是使用的 Docker On Docker 的模式,这是因为 Kubernetes 集群使用的是 Docker 这种容器运行时,所以我们可以将宿主机的 docker.sock 文件挂载到容器中构建镜像,而最近我们在使用 Kubernetes 1.22.X 版本后将容器运行时更改为了 Containerd,这样节点上没有可用的 Docker 服务了,这个时候就需要更改构建镜像的模式了,当然要实现构建镜像的方式有很多,我们这里还是选择使用 Docker 来构建我们的 Docker 镜像,也就是使用 Docker IN Docker 的模式。
我是阳明
2021/11/17
1.5K0
Docker搭建自己的Gitlab CI Runner
哎_小羊
2018/01/02
14.7K0
Docker搭建自己的Gitlab CI Runner
Docker中搭建CI环境
在之前的文章中介绍了Gitlab环境的搭建和CI与Gitlab的整合,那么今天主要介绍Docker中搭建CI的环境,Docker诞生于云计算的时代,它主要是基于Go语言实现的开源容器项目,目前关于Docker容器的生态系统已经很完善,而且各大主流的操作系统公司都支持Docker。今天主要介绍在Docker中搭建Jenkins的环境,关于Docker环境的搭建在后期的文章中逐步的介绍。CI就不需要多余的介绍了, 它是自动化测试中必须要掌握的一个技能之一,同时也是实现CICD整合的核心工具之一。
Criss@陈磊
2019/10/28
9160
Docker中搭建CI环境
Docker中搭建CI环境
在之前的文章中介绍了Gitlab环境的搭建和CI与Gitlab的整合,那么今天主要介绍Docker中搭建CI的环境,Docker诞生于云计算的时代,它主要是基于Go语言实现的开源容器项目,目前关于Docker容器的生态系统已经很完善,而且各大主流的操作系统公司都支持Docker。今天主要介绍在Docker中搭建Jenkins的环境,关于Docker环境的搭建在后期的文章中逐步的介绍。CI就不需要多余的介绍了, 它是自动化测试中必须要掌握的一个技能之一,同时也是实现CICD整合的核心工具之一。
无涯WuYa
2019/10/24
4390
Docker中搭建CI环境
【Podman】podman入门学习 | Docker替代品
在上手程度上:Podman 的操作方式与 Docker 高度兼容,很适合docker用户转型使用podman。使用命令几乎和docker相同
宝耶需努力
2022/12/13
1.7K0
【Podman】podman入门学习 | Docker替代品
docker containerd podman 对比
Docker、containerd和Podman是三种流行的容器技术,允许开发人员和系统管理员创建、运行和管理容器化应用程序。虽然这些技术之间有一些相似之处,但它们之间存在显着的差异。在本文中,我们将比较Docker、containerd和Podman。
堕落飞鸟
2023/03/26
3.3K0
podman初试-和docker对比
Docker 是一个开源的应用容器引擎,属于 Linux 容器的一种封装,Docker 提供简单易用的容器使用接口,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上。容器是完全使用沙箱机制,相互之间不会有任何接口。
张琳兮
2019/11/07
7.3K0
GitLab CI + Docker 持续集成操作手册
在传统软件的开发中,代码的集成工作通常是在所有人都将工作完成后在项目即将结束进行时,而这往往会花费大量的时间和精力。而持续集成是一种将集成阶段放在软件开发阶段的做法,以便更加有规律地构建,测试和集成代码。
蒋老湿
2020/07/31
1.1K0
GitLab CI + Docker 持续集成操作手册
使用 GitLab CI 和 Docker 自动部署 Spring Boot 应用
Docker和Spring Boot是非常流行的组合,我们将利用GitLab CI的优势,并在应用程序服务器上自动构建,推送和运行Docker镜像。
民工哥
2020/10/23
3.1K0
使用 GitLab CI 和 Docker 自动部署 Spring Boot 应用
mac使用podman替代docker
或者去https://github.com/containers/podman/releases下载对应的pkg
code4it
2023/08/31
2370
mac使用podman替代docker
mac使用podman替代docker
或者去https://github.com/containers/podman/releases下载对应的pkg
code4it
2023/06/01
5220
制作一个能构建 dotnet AOT 的 gitlab ruuner 的 Debian docker 镜像
我的需求是需要有一个能够构建出 dotnet 的 AOT 包的环境,要求这个环境能解决 glibc 兼容依赖的问题,能打出来 x64 和 arm64 的 AOT 的包,且能够运行 gitlab runner 对接自动构建
林德熙
2024/04/29
1740
制作一个能构建 dotnet AOT 的 gitlab ruuner 的 Debian docker 镜像
Podman 会取代 Docker 吗?
Linux容器 是与系统其他部分隔离开的一系列进程。运行这些进程所需的所有文件都由另一个镜像提供,这意味着从开发到测试再到生产的整个过程中,Linux 容器都具有可移植性和一致性。因而,相对于依赖重复传统测试环境的开发渠道,容器的运行速度要快得多。容器比较普遍也易于使用,因此也成了 IT 安全方面的重要组成部分。[1]
YP小站
2020/06/04
13.6K1
深入理解Docker:docker、podman-docker、docker.io和docker-ce的区别
今天我们要来了解一下关于Docker的一些知识,特别是在Ubuntu 22.04服务器上关于docker、podman-docker、docker.io以及docker-ce的区别。
buzzfrog
2024/01/09
5.2K0
在 Gitlab 中构建 Docker 镜像
有了 Gitlab CI 的脚本能力,又有容器镜像仓库的支持,自然的一个想法就是,在 Gitlab 上构建容器镜像,并推送到镜像仓库之中。
崔秀龙
2019/07/22
2.3K0
在 Gitlab 中构建 Docker 镜像
【GitLab】:安装GitLab——基于Docker
Before setting everything else, configure a new environment variable $GITLAB_HOME pointing to the directory where the configuration, logs, and data files will reside. Ensure that the directory exists and appropriate permission have been granted.
WEBJ2EE
2021/09/02
2.4K0
【GitLab】:安装GitLab——基于Docker
docker 部署Gitlab
今天看到有个人 把 docker 部署Gitlab 的文章设置为付费文档了 我就呵呵了。。。 我也来下一篇,免费的
拿我格子衫来
2022/01/25
3530
docker部署gitlab[通俗易懂]
这篇文章用来记录下我在使用docker部署gitlab时候遇到的一些坑。 先介绍下我的环境: 阿里云的轻量应用服务器:2核4G(好像最低要求配置,之前用2核2G的部署,直接给内存溢出),centos7.6
全栈程序员站长
2022/11/10
4.9K0
docker部署gitlab[通俗易懂]
Docker 部署 Gitlab
基于 docker 部署 gitlab 比较方便,但服务器至少需要 4GB 内存,否则可能出现 502 错误。
jwangkun
2021/12/23
1.1K0
什么是 Podman?替代 Docker的容器引擎
Podman 是 Red Hat 的一个开源项目,可以免费下载。它是容器化领域的一个相对较新的人,1.0 版将于 2019 年发布。此后 Podman 取得了长足的进步,其崛起伴随着 Docker 的逐渐衰落,该项目在许多方面创造了我们今天所知的容器世界。
低代码布道者
2022/07/28
12.5K0
什么是 Podman?替代 Docker的容器引擎

相似问题

在OS上用Docker运行Gitlab CI转轮

10

为GitLab应用程序部署没有Docker的NodeJS CI?

10

GitLab CE Docker - /etc/gitlab/gitlab.rb不按预期工作

10

作为非根用户运行容器的无根Docker和Podman有什么区别?

10

运行MySQL容器和共享数据目录的Podman (或docker)

10
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文