Docker in Docker for gitlab: Client sent an http request to https server / failed to remove network

Solution 1:

I had a similar use case (Jenkins CI), and ran into the same problem. I was able to work around it by not using docker in docker at all. Instead, I mounted /var/run/docker.sock into the docker container (i.e -v /var/run/docker.sock:/var/run/docker.sock). The URL for the docker daemon becomes unix:///var/run/docker.sock.

This suggestion came from https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ which is referred to directly from the official docker in docker image on dockerhub.

The only thing I had to alter on the container was to make sure my user was part of the docker group and that the docker group had the same gid on both the host and container.

Solution 2:

Disable TLS by setting env var DOCKER_TLS_CERTDIR=""

Source: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4501