How to use docker-compose.yml file in GitLab Runner server?

Hi,

All commands that are in script section are executed on the machine where is GitLab Runner, but details depends on your runner executor. It is all explained in the documentation: Get started with GitLab CI/CD | GitLab

If the executor is docker, Runner will create a container from the docker image specified in the job description (or by default the one that is in config.toml file of the runner).

If the executor is shell, it will be executed directly on the VM where the Runner is installed.

If you want to execute a job on some other machine, then you can either use ssh executor, or configure docker executor to scp (copy files) and ssh into another machine and execute commands. You can google around, or visit previous topics on the forum about this, e.g. Question on Deploy phase of gitlab-ci.yaml - #2 by paula.kokic

Example with docker executor (extension of the config I linked above):

script:
  - scp docker-compose.yml user@target-host:~/my-project/docker-compose.yml
  - ssh user@target-host "cd my-project && docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD && docker compose pull && docker compose up -d"
1 Like