1

Trying to build a docker image from withing shared runner, below is the CI configuration

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

connect to a TLS-enabled daemon without TLS? ERROR: Build failed: exit code 1

Tried with the same Base docker image in my local, to docker ps, which works after service docker start

I would like to package the application and create docker image within the same job, appreciate any help

Somasundaram Sekar
  • 5,244
  • 6
  • 43
  • 85

1 Answers1

0

Use different image for each stage, in your case use osrg/dind-ubuntu-vivid for build and test, and docker image in release stage with dind service. Check this thread.

Community
  • 1
  • 1