Mark24
记录灵感、技术、思考
Docker问题汇总
一、Docker-in-Docker 网络问题,无法连接tcp://docker:2375/
问题:
Docker报错如下
Docker in Docker is failing with error - Cannot connect to the Docker daemon at tcp://docker:2375/. Is the docker daemon running?
解决
build:docker:
image: docker:20-dind
variables:
# using "docker" as the host is only possible if you alias the service below
DOCKER_HOST: tcp://docker:2375
# could be wrong here but although Docker defaults to overlay2,
# Docker-in-Docker (DIND) does not according to the following GitLab doc:
# https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-the-overlayfs-driver
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
services:
- name: docker:20-dind
alias: docker
# in our experience although you'd assume this would be sufficient, this did
# nothing to prevent connection errors without `DOCKER_TLS_CERTDIR` being set
# to an empty string, and I would call that beyond mildly infuriating.
command: ["--tls=false"]
before_script:
- echo ${REGISTRY_PASSWORD} | docker login ${REGISTRY} -u ${REGISTRY_USER} --
password-stdin
- *version_info
script:
- docker build .
--tag ${CONTAINER_IMAGE}:$BUILD_VERSION
--tag ${CONTAINER_IMAGE}:latest
- docker push ${CONTAINER_IMAGE}:latest
- docker push ${CONTAINER_IMAGE}:$BUILD_VERSION