skip to Main Content

There are various questions on how to use docker or docker-compose from the gitlab-ci.

So I am using the following Docker-Images for my quest:

  • gitlab/gitlab-runner:latest (as the gitlab-runner instance)
  • docker/compose:1.29.2 (as gitlab-ci.yml executor image)
  • docker:dind (as service)
image: docker/compose:1.29.2

variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_HOSTNAME: myhost
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: ""

services:
  - name: docker:dind

stages:
  - composeTest

composeTest:
  stage: composeTest
  tags:
    - compose
  script:
    - ping -c 3 docker
    - docker-compose --version
    - docker-compose up -d
    - docker-compose down

Currently I disabled tls, I will work on this later. That is not content of this question!

In this script, the first two commands are successfully processed, but docker-compose up -d fails when it tries to pull the required images.

On my server I also have a .docker/config.json file with content like

{
        "auths": {
                "local.artifactory.corp.net": {
                        "auth": "VERY SECURE KEY!"
                }
        },
        "proxy": {
                "remoteurl": "local.artifactory.corp.net"
        }
}

I figured, I need this config.json available in the docker-container, that pulls the required images.

  • But which of the three afforementioned containers is it?
  • (How) can I get it there? (Without maintaining a custom version of it?)

2

Answers


  1. Chosen as BEST ANSWER

    Actually I was wrong and didn't need the config.json I found.

    Instead I needed a /etc/docker/daemon.json in the docker:dind-image with a line like

    "registry-mirrors": ["https://local.artifactory.corp.net"]
    

    I did not find a solution yet, on how to get it there, without creating a new image.


  2. All you really need to do is run docker login with your registry address/username/password.

    something like this

    composeTest:
      before_script:
        - docker login local.artifactory.corp.net -u derm -p $ARTIFACTORY_PASSWORD
    

    If you use SSO to sign into Artifactory, you may have to generate a token to use as your password.

    There are a few techniques to authenticate to a private registry from GitLab CI. You can also take advantage of DOCKER_AUTH_CONFIG environment variable mechanics, credential helpers, etc. This is explained in depth in the GitLab documentation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search