I don't know if this gonna help you, but you can use docker-compose instead:
Exemple of docker-compose.yml
version: '3.5'
services:
docker:
image: docker:18.09.0-dind
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker
entrypoint: /bin/sh
command: -c "docker network create gitlab-runner-net;
docker run -d --name gitlab-dind --privileged
--restart always --network gitlab-runner-net
-v /var/lib/docker docker:17.06.0-ce-dind"
Then docker-compose up -d
Starting dk_docker_1 ... done
Attaching to dk_docker_1
docker_1 | 66fdfc18e290814cff7b1d8cb75acf575e22cc5b4d3478e0274b82043f0d493c
docker_1 | e3a2deb36d8a8b71aef86b2a73455a2a1cd5fa99c4e961a125421ca7aefd2e14
dk_docker_1 exited with code 0
Then on the host:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e3a2deb36d8a docker:17.06.0-ce-dind "dockerd-entrypoint.…" 45 seconds ago Up 44 seconds 2375/tcp gitlab-dind
then run docker inside docker:
docker exec -it 05e7f866382b docker run -d alpine sleep 300
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
801bfaa63ef2: Pull complete
Digest: sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436
Status: Downloaded newer image for alpine:latest
06a481b6692d6e4ef19ca4bd95ddc403c08a828817dc66092343ddd3e0690f27
docker exec -it 05e7f866382b docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
06a481b6692d alpine "sleep 300" 12 seconds ago Up 12 seconds peaceful_snyder
This is just an example you will have to properly setup networks, volumes etc ...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…