From a34f3ba24dfdebce0a3b13242f5e259ebe9c6ce0 Mon Sep 17 00:00:00 2001 From: Marcel Feix Date: Tue, 14 Jun 2022 18:35:09 +0200 Subject: [PATCH] feat(Dind): Test dind containers --- .../templates/container/docker-in-docker.adoc | 12 ++++++++++ .../container/docker-in-docker.gitlab-ci.yml | 22 +++++++++++++++++++ test/docker/test-dind.gitlab-ci.yml | 18 ++++----------- 3 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 documentation/chapters/templates/container/docker-in-docker.adoc create mode 100644 templates/container/docker-in-docker.gitlab-ci.yml diff --git a/documentation/chapters/templates/container/docker-in-docker.adoc b/documentation/chapters/templates/container/docker-in-docker.adoc new file mode 100644 index 0000000..def22cd --- /dev/null +++ b/documentation/chapters/templates/container/docker-in-docker.adoc @@ -0,0 +1,12 @@ +:sourcedir: ../../../../templates/ + += Docker in Docker + +This template helps to start jobs, that need a docker environment to run. +Simply expand from this Template. + +.container scan template +[source,yaml] +---- +include::{sourcedir}container/docker-in-docker.gitlab-ci.yml[] +---- \ No newline at end of file diff --git a/templates/container/docker-in-docker.gitlab-ci.yml b/templates/container/docker-in-docker.gitlab-ci.yml new file mode 100644 index 0000000..f5b7c64 --- /dev/null +++ b/templates/container/docker-in-docker.gitlab-ci.yml @@ -0,0 +1,22 @@ +.docker-in-docker: + services: + - name: docker:20.10.17-dind + command: + - "--registry-mirror" + - "https://nexus.corp.exxcellent.de:18000" + - "--insecure-registry" + - "nexus.corp.exxcellent.de:18000" + - "--insecure-registry" + - "gitlab.exxcellent.de:4567" + # explicitly disable tls to avoid docker startup interruption + - "--tls=false" + alias: docker + variables: + # Instruct Testcontainers to use the daemon of DinD. + DOCKER_HOST: "tcp://docker:2375" + # Instruct Docker not to start over TLS. + DOCKER_TLS_CERTDIR: "" + # Improve performance with overlayfs. + DOCKER_DRIVER: overlay2 + # Needed by testcontainers https://www.testcontainers.org/supported_docker_environment/continuous_integration/gitlab_ci/ + TESTCONTAINERS_HOST_OVERRIDE: "host.docker.internal" \ No newline at end of file diff --git a/test/docker/test-dind.gitlab-ci.yml b/test/docker/test-dind.gitlab-ci.yml index 0c9a5e7..ceb6c7a 100644 --- a/test/docker/test-dind.gitlab-ci.yml +++ b/test/docker/test-dind.gitlab-ci.yml @@ -1,22 +1,12 @@ +include: + local: "templates/container/docker-in-docker.gitlab-ci.yml" + stages: - verify -services: - - name: docker:dind - # explicitly disable tls to avoid docker startup interruption - command: [ "--tls=false" ] - alias: docker - -variables: - # Instruct Testcontainers to use the daemon of DinD. - DOCKER_HOST: "tcp://docker:2375" - # Instruct Docker not to start over TLS. - DOCKER_TLS_CERTDIR: "" - # Improve performance with overlayfs. - DOCKER_DRIVER: overlay2 - Test-Simple-Dind: image: docker:stable + extends: .docker-in-docker stage: verify script: - docker run -t alpine echo test \ No newline at end of file