diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d61dcb6bdff951abf84b4db6b6d61b10c0108c12..dd280455d50800b40cd934bcfaaaed3aa1dc9da9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,23 @@ image: docker:latest
 services:
 - docker:dind
 
+.dind_base:
+  tags: [dind]
+  image: docker/compose:1.29.2
+  variables:
+    DOCKER_TLS_CERTDIR: ""
+    DOCKER_HOST: tcp://docker:2375
+  services:
+    - name: docker:dind
+      command: [dockerd, '-H', 'tcp://0.0.0.0:2375']
+  before_script:
+    # docker login asks for the password to be passed through stdin for security
+    # we use $CI_REGISTRY_PASSWORD here which is a special variable provided by GitLab
+    # https://docs.gitlab.com/ce/ci/variables/predefined_variables.html
+    - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
+
 build-image:
+  extends: .dind_base
   script:
     - docker build -t $CI_REGISTRY_IMAGE slides/.
     - docker push $CI_REGISTRY_IMAGE
\ No newline at end of file