1

尝试从共享运行器构建 docker 映像,以下是 CI 配置

image: osrg/dind-ubuntu-vivid

services:
  - docker:dind

stages:
    - build
    - test
    - release

variables:
  CONTAINER_TEST_IMAGE: registry.gitlab.com/somasundaramsekar/ci-test:$CI_BUILD_REF_NAME
  CONTAINER_RELEASE_IMAGE: registry.gitlab.com/somasundaramsekar/ci-test:latest

before_script:
  - apt-get update -y >/dev/null 2>&1
  - apt-get install -y --fix-missing software-properties-common python-software-properties >/dev/null 2>&1
  - apt-get update -y >/dev/null 2>&1
  - apt-get install -y openjdk-8-jdk >/dev/null 2>&1
  - apt-get install apt-transport-https -y >/dev/null 2>&1
  - wget www.scala-lang.org/files/archive/scala-2.11.7.deb >/dev/null 2>&1
  - dpkg -i scala-2.11.7.deb >/dev/null 2>&1
  - scala -version
  - echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list
  - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823 >/dev/null 2>&1
  - apt-get update >/dev/null 2>&1
  - apt-get install -y sbt >/dev/null 2>&1
  - wget https://downloads.typesafe.com/typesafe-activator/1.3.10/typesafe-activator-1.3.10.zip >/dev/null 2>&1
  - apt-get install -y unzip >/dev/null 2>&1
  - unzip typesafe-activator-1.3.10.zip >/dev/null 2>&1
  - export ACTIVATOR_HOME="$(pwd)/activator-dist-1.3.10"
  - export PATH=$PATH:$ACTIVATOR_HOME/bin
  - service docker start
  - docker ps
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com

build:
  stage: build
  script:
    - sbt clean compile


test:
  stage: test  
  script:
    - sbt clean coverage test coverageReport

release:
    stage: release
    script:
     - activator dist
     - docker build --pull -t $CONTAINER_TEST_IMAGE .
     - docker push $CONTAINER_TEST_IMAGE 


But when the job runs it fails like below
 * Starting Docker: docker
   ...done.
$ docker ps
Get http:///var/run/docker.sock/v1.19/containers/json: dial unix /var/run/docker.sock: no such file or directory. Are you trying to

连接到没有 TLS 的启用 TLS 的守护进程?错误:构建失败:退出代码 1

尝试在我的本地 to 中使用相同的 Base docker 映像,docker ps之后可以使用service docker start

我想打包应用程序并在同一个工作中创建 docker 映像,感谢任何帮助

4

1 回答 1

0

为每个阶段使用不同的图像,在您的情况下osrg/dind-ubuntu-vivid用于构建和测试,以及在发布阶段使用 dind 服务的 docker 图像。检查这个线程

于 2016-10-03T10:59:35.117 回答