-
Notifications
You must be signed in to change notification settings - Fork 179
Open
Labels
bugSomething isn't workingSomething isn't working
Description
gitlab-ci-local Docker-in-Docker TLS Troubleshooting
This document summarizes the environment configuration, troubleshooting commands, and outputs from attempts to run Docker-in-Docker (dind) in parallel on a local host using gitlab-ci-local.
Example Pipeline YAML
# .gitlab-ci.yml
stages:
- test
dind_job_1:
stage: test
image: docker:latest
services:
- name: docker:dind
alias: docker
variables:
DOCKER_TLS_CERTDIR: "/certs"
script:
- docker info
dind_job_2:
stage: test
image: docker:latest
services:
- name: docker:dind
alias: docker
variables:
DOCKER_TLS_CERTDIR: "/certs"
script:
- docker infoExample Variable Files
.gitlab-ci-local-env
# shellcheck shell=bash
PRIVILEGED=true
ULIMIT=8000:16000
VOLUME=certs:/certs/client
VARIABLE="DOCKER_TLS_CERTDIR=/certs".gitlab-ci-local-variables.yml
CI_REGISTRY: gitlab-ci-local-registry:5000Troubleshooting Commands and Outputs
1. Compare CA Cert SHA1 Sums
First Pair (Works)
docker exec vibrant_williams sha1sum /certs/server/ca.pem
# Output:
601b24954f25a212bcb732993dfee3cfaf845dfc /certs/server/ca.pem
docker exec adoring_allen sha1sum /certs/client/ca.pem
# Output:
601b24954f25a212bcb732993dfee3cfaf845dfc /certs/client/ca.pemSecond Pair (Fails)
docker exec gracious_kalam sha1sum /certs/server/ca.pem
# Output:
21475f6e70402ebef8c5235dad35a344f18768b3 /certs/server/ca.pem
docker exec agitated_shirley sha1sum /certs/client/ca.pem
# Output:
601b24954f25a212bcb732993dfee3cfaf845dfc /certs/client/ca.pem2. Show CA Certificate Details
vibrant_williams (dind, works)
docker exec vibrant_williams openssl x509 -in /certs/server/ca.pem -noout -serial
# Output:
serial=7E5C55666CF686AE4FBCB178CECFACF03BB542B7adoring_allen (client, works)
docker exec adoring_allen openssl x509 -in /certs/client/ca.pem -noout -serial
# Output:
serial=7E5C55666CF686AE4FBCB178CECFACF03BB542B7gracious_kalam (dind, fails)
docker exec gracious_kalam openssl x509 -in /certs/server/ca.pem -noout -serial
# Output:
serial=2B76F691BEF8870EF48477FFA8A6830BB776DED5agitated_shirley (client, fails)
docker exec agitated_shirley openssl x509 -in /certs/client/ca.pem -noout -serial
# Output:
serial=7E5C55666CF686AE4FBCB178CECFACF03BB542B73. Verify Client Certificate
adoring_allen (works)
docker exec adoring_allen openssl verify -CAfile /certs/client/ca.pem /certs/client/cert.pem
# Output:
/certs/client/cert.pem: OKagitated_shirley (fails)
docker exec agitated_shirley openssl verify -CAfile /certs/client/ca.pem /certs/client/cert.pem
# Output:
/certs/client/cert.pem: OK4. Inspect Container Mounts
adoring_allen
docker inspect --format '{{range .Mounts}}{{println .Destination}}{{end}}' adoring_allen
# Output:
/builds/user/devops
/tmp/gitlab-ci-local-file-variables-user-devops-776734
/certs/client
/var/lib/dockervibrant_williams
docker inspect --format '{{range .Mounts}}{{println .Destination}}{{end}}' vibrant_williams
# Output:
/builds/user/devops
/tmp/gitlab-ci-local-file-variables-user-devops-776734
/var/lib/docker
/certs/clientagitated_shirley
docker inspect --format '{{range .Mounts}}{{println .Destination}}{{end}}' agitated_shirley
# Output:
/builds/user/devops
/tmp/gitlab-ci-local-file-variables-user-devops-956815
/certs/client
/var/lib/dockergracious_kalam
docker inspect --format '{{range .Mounts}}{{println .Destination}}{{end}}' gracious_kalam
# Output:
/tmp/gitlab-ci-local-file-variables-user-devops-956815
/var/lib/docker
/certs/client
/builds/user/devops5. Docker Info
adoring_allen (works)
docker exec adoring_allen docker info
# Output: (Docker info, no errors)agitated_shirley (fails)
docker exec agitated_shirley docker info
# Output:
error during connect: Get "https://docker:2376/v1.51/info": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "docker:dind CA")
Command exited with code 1Summary of Findings
- Only the first job/service pair (
adoring_allen+vibrant_williams) shares matching CA certs and works. - Subsequent pairs (
agitated_shirley+gracious_kalam) have mismatched CA certs between client and dind, causing TLS errors. - All containers have
/certs/clientmounted, but the contents of the volume differ between pairs. - This appears to be a bug in gitlab-ci-local's handling of named volumes and certificate generation for parallel jobs/services.
Expected Behavior
- All job/service pairs should share the same CA certs when using a named volume for
/certs/client. - Docker TLS should work for all pairs, not just the first.
Actual Behavior
- Only the first pair works; others fail with TLS verification errors due to CA mismatch.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working