【问题标题】:build and push docker images with GitLab CI使用 GitLab CI 构建和推送 docker 镜像
【发布时间】:2018-02-13 09:37:40
【问题描述】:

我想使用 GitLab CI 构建 docker 镜像并将其推送到我的本地 nexus 存储库

这是我当前的 CI 文件:

image: docker:latest

services:
  - docker:dind

before_script:
  - docker info
  - docker login -u some_user -p nexus-rfit some_host

stages:
  - build

build-deploy-ubuntu-image:
  stage: build
  script:
    - docker build -t some_host/dev-image:ubuntu ./ubuntu/
    - docker push some_host/dev-image:ubuntu
  only:
    - master
  when: manual

还有一个 alpin docker 的工作,但是当我想运行它时,它会失败并出现以下错误:

正在检查 13102ac4 作为主...跳过 Git 子模块设置 $ docker info 无法连接到 Docker 守护进程 unix:///var/run/docker.sock。 docker 守护进程是否正在运行?错误:工作 失败:退出代码 1

所以从技术上讲,镜像中的 docker 守护进程没有运行,但我不知道为什么?

【问题讨论】:

    标签: gitlab gitlab-ci gitlab-ci-runner


    【解决方案1】:

    GitLab 人员在他们的文档中有一个关于在基于 docker 的作业中使用 docker-build 的参考:https://docs.gitlab.com/ce/ci/docker/using_docker_build.html#use-docker-in-docker-executor。由于您似乎一切就绪(即工作的正确图像和额外的docker:dind 服务),这很可能是运行器配置问题。

    如果您查看文档中的第二步:

    1. 从命令行注册 GitLab Runner 以使用 docker 和特权模式:

      [...]

      注意它使用特权模式来启动构建和服务容器。如果你想使用 docker-in-docker 模式,你总是必须在你的 Docker 容器中使用privileged = true

    您可能正在使用 未在特权模式下配置的运行器,因此无法正确运行内部的 docker 守护程序。您可以直接在您注册的跑步者上编辑/etc/gitlab-runner/config.toml 以添加该选项。

    (另外,请阅读文档部分,了解有关您选择的存储驱动程序/您的跑步者在使用 dind 时支持的性能的更多信息)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      • 1970-01-01
      • 2020-08-09
      • 1970-01-01
      • 2019-08-03
      • 1970-01-01
      • 2021-02-27
      相关资源
      最近更新 更多