npm install freezes when using Docker in Docker

Summary

npm install does not work on Gitlab Runner in Kubernetes (deployed with the gitlab/gitlab chart). It freezes and the job time outs.

Steps to reproduce

.gitlab-ci.yml
stages:
  - build

node:
  stage: build
  image: docker
  services:
    - docker:dind
  variables:
    DOCKER_HOST: tcp://localhost:2375
    DOCKER_TLS_CERTDIR: ""
  script:
    - docker build -t node node
Dockerfile
FROM node:13-alpine

WORKDIR /app
RUN npm install --verbose express
COPY . .

CMD [ "npm", "start" ]

Actual behavior

The job freezes when it comes to npm install. The command works fine outside of DIND. The Docker image is built successfully on Docker Desktop and Ubuntu 19.10.

Expected behavior

NPM should install the packages.

Relevant logs and/or screenshots

job log
 Running with gitlab-runner 12.6.0 (ac8e767a)
   on gitlab-gitlab-runner-74c49f8cf6-mpwsn rQjz31_1
Using Kubernetes namespace: gitlab
00:00
 Using Kubernetes executor with image docker ...
Waiting for pod gitlab/runner-rqjz311-project-4-concurrent-75tgjr to be running, status is Pending
 Waiting for pod gitlab/runner-rqjz311-project-4-concurrent-75tgjr to be running, status is Pending
 Running on runner-rqjz311-project-4-concurrent-75tgjr via gitlab-gitlab-runner-74c49f8cf6-mpwsn...
Fetching changes with git depth set to 50...
00:01
 Initialized empty Git repository in /builds/ThePicoNerd/ci-testing/.git/
 Created fresh repository.
 From https://gitlab.lynx.agency/ThePicoNerd/ci-testing
  * [new ref]         refs/pipelines/27 -> refs/pipelines/27
  * [new branch]      ThePicoNerd-master-patch-57177 -> origin/ThePicoNerd-master-patch-57177
 Checking out 478d18cd as ThePicoNerd-master-patch-57177...
 Skipping Git submodules setup
$ docker build -t node node
 Step 1/5 : FROM node:13-alpine
 13-alpine: Pulling from library/node
 c9b1b535fdd9: Pulling fs layer
 07b35de5c8a5: Pulling fs layer
 a0b0418c013a: Pulling fs layer
 f4ac4306c751: Pulling fs layer
 f4ac4306c751: Waiting
 c9b1b535fdd9: Verifying Checksum
 c9b1b535fdd9: Download complete
 a0b0418c013a: Verifying Checksum
 a0b0418c013a: Download complete
 c9b1b535fdd9: Pull complete
 f4ac4306c751: Verifying Checksum
 f4ac4306c751: Download complete
 07b35de5c8a5: Download complete
 07b35de5c8a5: Pull complete
 a0b0418c013a: Pull complete
 f4ac4306c751: Pull complete
 Digest: sha256:23e2fc644a6f3bc8d48b56cb57f05a96827dac88b6534e8fab538a23e9c23993
 Status: Downloaded newer image for node:13-alpine
  ---> b809734bb743
 Step 2/5 : WORKDIR /app
  ---> Running in ad480c598fe7
 Removing intermediate container ad480c598fe7
  ---> e8bc277d4661
 Step 3/5 : RUN npm install --verbose express
  ---> Running in a8d589002536
 npm info it worked if it ends with ok
 npm verb cli [
 npm verb cli   '/usr/local/bin/node',
 npm verb cli   '/usr/local/bin/npm',
 npm verb cli   'install',
 npm verb cli   '--verbose',
 npm verb cli   'express'
 npm verb cli ]
 npm info using npm@6.13.6
 npm info using node@v13.7.0
 npm verb npm-session 37a36ac818a1d875

Environment description

I use Kubernetes Gitlab Runner deployed with the gitlab/gitlab Helm chart.

values.yaml contents
gitlab-runner:
  checkInterval: 10
  runners:
    privileged: true

Used GitLab Runner version

Possible fixes