Version: Gitlab.com with local (EC2-based) runners
Problem:
I’ve hit an odd error where my dind-based docker builds fail when using an image pulled from the dependency proxy (CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX), but run correctly when pulling the image directly from docker.
The configuration pasted below fails with the error “error during connect: Post http://docker:2375/v1.40/auth: dial tcp: lookup docker on :53:no such host”. However, if I change the services: name entry to “docker:19.03.12-dind”; i.e., I remove the “CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX” portion, it works properly.
.gitlab-ci.yml:
.dockerbuildpush: &dockerbuildpush
- apk -q add py3-pip
- pip install awscli --upgrade --user
- /root/.local/bin/aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $SHARED_AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
- docker build . -t $REPOSITORY_NAME:$CI_COMMIT_SHA
- docker tag $REPOSITORY_NAME:$CI_COMMIT_SHA $SHARED_AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:$CONTAINER_VERSION
- docker push $SHARED_AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:$CONTAINER_VERSION
buildpushdev:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:19.03.12
stage: buildpush
tags:
- pdpdevinternal
rules:
- if: '$CI_COMMIT_BRANCH == "develop"'
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:19.03.12-dind
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
CONTAINER_VERSION: develop
AWS_REGION: us-east-1
SHARED_AWS_ACCOUNT_ID: redacted
REPOSITORY_NAME: redacted
script:
- *dockerbuildpush
Troubleshooting tried: Originally, I experienced this same problem using “docker:stable-dind”, but the gitlab support docs recommended that I specify the version, as seen above. I’ve followed the various fix recommendations in Docker:dind stops working after 12.1.0 update - #3 by timspin, including adding (to services):
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:19.03.12-dind
# entrypoint: ["env", "-u", "DOCKER_HOST"]
# command: ["dockerd-entrypoint.sh"]
#- docker:stable-dind
and (to variables):
#DOCKER_HOST: tcp://docker:2375/
But that didn’t change anything, either.