Hi all!
I have a self-hosted docker registry with a self-sign certificate. I'm trying to push docker image to this registry but getting the following error:
x509: certificate signed by unknown authority
I can not understand why, since on my local machine (on which I'm running ci runner) everything seems to work fine (I've created a path in /etc/docker/certs.d/address_to_registry/ca.crt). I am also able to mount docker.sock to docker image and push everything to the registry.
The step that is failing looks as follows:
- step:
name: Deploy to Production
deployment: Production
runs-on: self.hosted
script:
- IMAGE_NAME=$BITBUCKET_REPO_SLUG
- docker load --input "${IMAGE_NAME}.tar"
- VERSION="prod-0.1.${BITBUCKET_BUILD_NUMBER}"
- IMAGE=${REGISTRY_URL}/${IMAGE_NAME}
- docker tag "${IMAGE_NAME}" "${IMAGE}:${VERSION}"
- docker push "${IMAGE}:${VERSION}"
services:
- docker
I don't quite understand how the docker service works. Does it not use "docker.sock" mounted to the runner? If it does it should verify my registry certificate. Maybe I'm missing something in the documentation but I have no idea how to debug this to resolve my problem. I also tried to pass the certificate to this step and install it via the "update-ca-certificates" tool but still gets the same error.
EDIT 1: The strangest thing is that in another pipeline (on same runner) I'm using images from this repository (using "image: my_repo/my_image:tag") and the image pulls with no problems. It seems like using the "services" keyword breaks everything.
EDIT 2: I'm using the "atlassian/default-image:3" for the problematic step.
Any ideas will be appreciated.
Hi @jczornik
Thank you for contacting Atlassian Support, my name is Norbert and I'm a Bitbucket Cloud Support Engineer, it's nice to meet with you. Welcome to the Atlassian Community!
Unfortunately the problem here is that you would need to restart the Docker daemon after you did the "update-ca-certificates" command, but unfortunately it's not yet supported with PIpelines. You can read further about this on the following thread
As a workaround, can you create a certificate (for example with Letsencrypt) and set up your Docker Registry, that way that it's using the new certificates? This way, once your Runner will try to connect to the registry, it will accept the certificate.
Please let me know how it goes.
Best Regards,
Norbert
Atlassian Bitbucket Cloud Support
Ok! I think I know, what is going on. If I use the docker service it does not mount the docker.sock file. Instead, it runs some kind docker in docker solution. The workaround is to define your own docker service like:
definitions:
services:
docker-custom:
type: docker
image: docker:dind
variables:
DOCKER_HOST: "tcp://localhost:2375"
DOCKER_TLS_CERTDIR: ""
CA_CERTIFICATE: "${REGISTRY_CERT}"
I'm not sure how to pass the certificate using the variable since for whatever reason custom variables do not accept newline characters (sick!) but it is different problem.
EDIT 1: This solution will not work either since there is no way to edit the entry point for the docker service.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.