CircleCI uses a TCP endpoint (echo $DOCKER_HOST
) and not the unix socket to communicate with the docker deamon (on another docker machine).
Mounting volumes won't work: /var/run/docker.sock:/var/run/docker.sock
fails. Source circleCI building-docker-images and circleCI docker-compose
Setup traefik with a TCP endpoint :
- You need to copy the certificats:
cp -R $DOCKER_CERT_PATH ./circle-cert
(after you ran- setup_remote_docker
in you circle file) - Then
docker build -t traefik-ci Dockerfile
(see the dockerfile next). - You can run
docker run --rm -p 80:80 --name traefik-reverse-proxy traefik-ci -l debug --docker --docker.endpoint=$DOCKER_HOST --docker.tls=true --docker.tls.ca=/cert/ca.pem --docker.tls.key=/cert/key.pem --docker.tls.cert=/cert/cert.pem --docker.tls.insecureskipverify=true
.
Thanks to https://discuss.circleci.com/t/gcloud-docker-push-image/15040 and https://discuss.circleci.com/t/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock/12195 for the inspiration.
If something is wrong, say it here! Hope this helps.
Thanks for this. I think I'm doing something wrong though as I still see it complaining about trying to connect to the daemon at
http+docker://localhost
- have you had to make any updates to this in the last two years?We run traefik via a separate docker compose file called
proxy.yml
so I'm not sure how to pass the docker options to it this way.