gitlab ci: 'compose' is not a docker command

18 Views Asked by At

I need to use docker compose in my gitlab CI, but I've got following error: "'compose' is not a docker command.". Also I've checked my server and Docker Compose version v2.26.0 installed.

By the way when I use old syntax 'docker-compose' and call docker-compose version, CI returns 'docker-compose version 1.25.0'.

My .gitlab-ci.yml file

deploy:
  image: docker:latest

  before_script:
    - docker version
    - docker-compose version
  script:
    - docker info

Docker version log:

Client:
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.3
 Git commit:        24.0.5-0ubuntu1~20.04.1
 Built:             Mon Aug 21 19:50:14 2023
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.3
  Git commit:       24.0.5-0ubuntu1~20.04.1
  Built:            Mon Aug 21 19:50:14 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.2
  GitCommit:        
 runc:
  Version:          1.1.7-0ubuntu1~20.04.2
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        

Maybe you know why this happens?

1

There are 1 best solutions below

0
Alex Dalen On BEST ANSWER

So, I've found my mistake.

  1. First of all gitlab-runner should be created by this command:
sudo gitlab-runner register -n \
  --url "https://gitlab.com/" \
  --registration-token REGISTRATION_TOKEN \
  --executor docker \
  --description "My Docker Runner" \
  --docker-image "docker:24.0.5" \
  --docker-privileged \
  --docker-volumes "/certs/client"
  1. gitlab-ci.yml should look like this:
deploy:
  image: docker:24.0.5

  services:
    - docker:24.0.5-dind

  before_script:
    - df
    - cat /etc/resolv.conf
    - cat /etc/hosts
    - docker version

  script:
    - docker info