cruizba / ubuntu-dind

A docker image based in ubuntu to run docker containers inside docker containers
Apache License 2.0
169 stars 76 forks source link

example gitlab-ci job #3

Closed arun-prakash-fokus closed 1 year ago

arun-prakash-fokus commented 3 years ago

I am trying to use your image to run inside a gitlab-ci job as follows:

stages:
    - test

test_bootstrap_ubuntu-dind:
  # test the bootstrap with DIND
  stage: test
  tags:
    - docker
  image:
    name: cruizba/ubuntu-dind:latest
  services:
    - name: docker:20-dind
      alias: docker    
  before_script:
    - echo "before script"
  script:
    - echo "inside script"
    - ls -l

and get the following console messages:

[Thu Apr  1 21:09:16 UTC 2021] [INFO] [/usr/local/bin/startup.sh] Process dockerd is not running yet. Retrying in 1 seconds
[Thu Apr  1 21:09:16 UTC 2021] [INFO] [/usr/local/bin/startup.sh] Waited 29 seconds of 30 seconds
[Thu Apr  1 21:09:17 UTC 2021] [ERROR]  dockerd is not running after max time

what am doing wrong? do you have any suggestions?

cruizba commented 3 years ago

I don't know how gitlab ci works, but this error usually happens if you don't run the container as --privileged. Reminder that this is not secure, but there is no other way to run docker in docker without "extra" features.

Anyways, there are better solutions like this https://github.com/nestybox/sysbox

eumel8 commented 3 years ago

It works for me in general with an priviledged gitlab-runner and when I run /usr/local/bin/startup.sh in the script section again. Entrypoint might be overwritten as described in GitlabEE Docs

I had also the need for run ubuntu-dind, which is the reason why I landed here by Google search. My constraints are

image: docker:dind

variables:
  DOCKER_DRIVER: overlay2
  DOCKER_HOST: tcp://localhost:2375
  DOCKER_TLS_CERTDIR: ''
  DEBIAN_FRONTEND: noninteractive
  BAZEL_VERSION: "4.0.0"

services:
  - name: docker:dind
    alias: docker   

stages:
  - build

build:
  image: ubuntu:20.04
  tags:
    - k8s-executor
  stage: build
  script:
    - echo "install packages"
    - apt-get update && apt-get -y upgrade
    - apt-get install -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew bash curl wget git openssl make python3-dev python3-pip gcc g++ docker.io
    - echo "install bazel"
    - wget -q https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-x86_64
    - chmod +x bazel-${BAZEL_VERSION}-linux-x86_64
    - mv bazel-${BAZEL_VERSION}-linux-x86_64 /usr/local/bin/bazel
    #... doing things with bazel and build an image to push