diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 14bd71b65d1edad399dfbb1ca3021255c389de8a..806c6ade353000c815d77f992fe89c40e8bdb71b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,7 +11,7 @@ variables:
   # Note that if you're using Kubernetes executor, the variable should be set to
   # tcp://localhost:2375 because of how Kubernetes executor connects services
   # to the job container
-  DOCKER_HOST: tcp://localhost:2375/
+  DOCKER_HOST: tcp://docker:2375/
   # When using dind, it's wise to use the overlayfs driver for
   # improved performance.
   DOCKER_DRIVER: overlay2
@@ -20,7 +20,8 @@ variables:
 
 services:
   - name: docker:dind
-    entrypoint: ["dockerd"]
+    entrypoint: ["env", "-u", "DOCKER_HOST"]
+    command: ["dockerd"]
 
 stages:
   - base