Using CI to build with docker-compose but cannot login to registry with self-signed cert

I have an internal gitlab project which we run on our server using a docker image. We use a self-signed certificate. We build our project with docker-compose and I’m trying to move this to use gitlab’s CI.

I created gitlab-ce.yml based on the instructions for a docker build here.
I replaced the docker image with docker/compose so that docker-compose is available to build with.

Initially there were problems with this failing to login to the registry because of the self-signed certificate. After some investigation, I updated the gitlab-ce.yml to add an --insecure-registry option to hopefully get the docker login command work based on these instructions. Even with that change I still get the same error.

The final gitlab-ce.yml looks like:

  image: docker/compose:latest
  stage: build
    - name: docker:dind
      command: [""]
    - echo “(token)” | docker login -u referral-manager --password-stdin $CI_REGISTRY
    - docker-compose build --pull
    - docker tag proxy "$CI_REGISTRY:proxy/$CI_COMMIT_REF_SLUG" .
    - docker push "$CI_REGISTRY:proxy/$CI_COMMIT_REF_SLUG" .
    - docker tag referee "$CI_REGISTRY:proxy/$CI_COMMIT_REF_SLUG" .
    - docker push "$CI_REGISTRY:referee/$CI_COMMIT_REF_SLUG" .
    - docker tag referral-manager "$CI_REGISTRY:proxy/$CI_COMMIT_REF_SLUG" .
    - docker push "$CI_REGISTRY:referral-manager/$CI_COMMIT_REF_SLUG" .
    - master

This still doesn’t work though and in the logs I’m seeing the error:

$ echo “(token)” | docker login -u referral-manager --password-stdin $CI_REGISTRY
time="2020-06-25T04:39:50Z" level=info msg="Error logging in to v2 endpoint, trying next endpoint: Get x509: certificate signed by unknown authority"
Get x509: certificate signed by unknown authority

I can’t seem to get the magic I need to be able to login to the gitlab registry. Can anyone help?