How to use Docker Compose In Gitlab CI

What are valid way to run docker compose inside a Gitlab CI. As I have tried to go with:|

docker-compose-playgroound:
    stage: docker-compose-playgroound
    image: docker:18
    services:
        - docker:18-dind
    tags:
        - docker-main
    variables:
        DOCKER_TLS_CERTDIR: ""
        DOCKER_HOST: tcp://docker:2375
    script:
        - docker compose -f .gitlab/docker-compose-autotests.yml up

However it has resulted in error:

$ docker compose -f .gitlab/docker-compose-autotests.yml up
unknown shorthand flag: 'f' in -f
See 'docker --help'.
Usage: docker [OPTIONS] COMMAND

The settings for my gitlab runner looks the following way:

 18 [[runners]]
 19   name = "xxxx"
 20   url = "https://gitlab.xxx/"
 21   token = "xxxxx"
 22   executor = "docker"
 23   [runners.custom_build_dir]
 24   [runners.cache]
 25     [runners.cache.s3]
 26     [runners.cache.gcs]
 27     [runners.cache.azure]
 28   [runners.docker]
 29     tls_verify = true
 30     image = "docker:18"
 31     privileged = false
 32     disable_entrypoint_overwrite = false
 33     oom_kill_disable = false
 34     disable_cache = false
 35     volumes = ["/home/gitlab-runner/cache"]
 36     cache_dir = "/home/gitlab-runner/cache"
 37     shm_size = 0

Please help me to fix it, or to help to use docker compose in a valid way within Gitlab CI. Any tips or advices are appreciated

1 Like

That almost seems like a unicode error thinking that your f is different that a linux f

for a test can you do the following

# assuming you don't have any other compose files in that folder
script: 
    - cd .gitlab
    - docker compose up

or

docker compose --file="./gitlab/docker-compose-autotests.yml" up

Did you find a way to make it work? Currently experiencing the same problems.