"docker run" always hangs when using docker in docker
Summary
"docker run" always hangs when using docker in docker
Steps to reproduce
The issue is reproduced automatically. See Example Project below.
- In a GitLab.com CI job use a docker image based on
alpine:edge
. - Install docker client and daemon.
- Run docker daemon in background.
- Run a simple command in a new container:
docker run busybox:latest echo hello
. - Observe: the command hangs.
Example Project
See https://gitlab.com/abogdanenko/dockerhangs.
The project contains just two files so I'm including them below.
Dockerfile
:
FROM alpine:edge
VOLUME /var/lib/docker
RUN apk upgrade && apk add --no-cache docker
.gitlab-ci.yml
:
build-docker-image:
image: docker
script:
- docker login --username "$CI_REGISTRY_USER" --password "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker build --tag "${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_NAME}" .
- docker push "${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_NAME}"
services:
- docker:dind
stage: build
docker-sanity-check:
image: ${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_NAME}
script:
- dockerd &
- sleep 10
- docker run busybox:latest echo hello
- killall dockerd
- sleep 15
- echo end-of-script
stage: test
stages:
- build
- test
The job timeout for the project is set to 10 minutes.
What is the current bug behavior?
The following command prints "hello" but never completes:
docker run busybox:latest echo hello
What is the expected correct behavior?
The following command completes in a reasonable time (less than 2 minutes):
docker run busybox:latest echo hello
Relevant logs and/or screenshots
$ docker run busybox:latest echo hello
...
ERROR: Job failed: execution took longer than 10m0s seconds
Output of checks
This bug happens on GitLab.com