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

I found this link and by adding the section to gitlab-ci.yml, I was able to finally login to the insecure registry.

I added:

variables: 
  DOCKER_TLS_CERTDIR: ''

and with that, I was able to login. I didn’t need to move the docker login command into the script section, it worked for me in the before_script section just fine.

God I’ve wasted a lot of time trying to get this to work. Thank you MerkAndreas!

The section in my gitlab-ci.yml looks like:

docker-build:
  image: docker:latest
  stage: build
  services:
    - name: docker:dind
      command: ["--insecure-registry=gitlab.object-craft.com.au:5050"]
  variables:
    DOCKER_TLS_CERTDIR: ''
  before_script:
    - echo "(token)" | docker login -u referral-manager --password-stdin $CI_REGISTRY
  script:
    - docker build --pull proxy -t "$CI_REGISTRY/proxy/$CI_COMMIT_REF_SLUG"
    - docker push "$CI_REGISTRY:proxy/$CI_COMMIT_REF_SLUG”
  except:
    - master