使用GitLab CI构建和推送docker映像

使用GitLab CI构建和推送docker映像,gitlab,gitlab-ci,gitlab-ci-runner,Gitlab,Gitlab Ci,Gitlab Ci Runner,我想用GitLab CI构建docker镜像并将其推送到我的本地nexus repo 这是我当前的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

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

这是我当前的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
还有一个阿尔宾码头工人的作业,但当我想运行其中任何一个作业时,它都会失败,并出现以下错误:

正在签出13102ac4作为主控。。。正在跳过Git子模块安装程序$ docker info无法连接到位于的docker守护程序 unix:///var/run/docker.sock. docker守护进程正在运行吗?错误:作业 失败:退出代码1


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

GitLab的人在他们的文档中有一个关于在基于docker的作业中使用docker build的参考:。由于您似乎已经准备好了一切(即作业的正确图像和附加的
docker:dind
服务),因此很可能是runner配置问题

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

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

    [……]

    请注意,它正在使用特权模式启动构建和服务容器。如果要在docker模式下使用docker,则必须始终在docker容器中使用
    privileged=true

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

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