J.Doe
J.Doe

Reputation: 199

docker compose in ado pipeline

I am trying to get docker-compose to run in the Azure Dev Ops pipeline with my yaml file but I keep getting errors like the following

Using docker-compose from 'dockerComposePath' 
##[error]/agent/_work/6/s/docker-compose.yml: 1: /agent/_work/6/s/docker-compose.yml: version:: not found
##[error]/agent/_work/6/s/docker-compose.yml: 2: /agent/_work/6/s/docker-compose.yml: services:: not found
##[error]/agent/_work/6/s/docker-compose.yml: 3: /agent/_work/6/s/docker-compose.yml: app1:: not found
##[error]/agent/_work/6/s/docker-compose.yml: 4: /agent/_work/6/s/docker-compose.yml: build:: not found
##[error]/agent/_work/6/s/docker-compose.yml: 5: /agent/_work/6/s/docker-compose.yml: context:: not found
##[error]/agent/_work/6/s/docker-compose.yml: 6: /agent/_work/6/s/docker-compose.yml: app2:: not found
##[error]/agent/_work/6/s/docker-compose.yml: 8: /agent/_work/6/s/docker-compose.yml: build:: not found
##[error]/agent/_work/6/s/docker-compose.yml: 9: /agent/_work/6/s/docker-compose.yml: ports:: not found
##[error]/agent/_work/6/s/docker-compose.yml: 10: /agent/_work/6/s/docker-compose.yml: -: not found
##[error]The process '/agent/_work/6/s/docker-compose.yml' failed with exit code 127

My docker-compose.yml is the following

  - task: DockerCompose@0
    displayName: 'Start docker compose'
    inputs:
      containerregistrytype: 'Container Registry'
      dockerComposePath: '$(Pipeline.Workspace)/s/docker-compose.yml'
      dockerComposeFile: 'docker-compose.yml'
      action: 'Run a Docker Compose command'
      dockerComposeCommand: 'up -d'

I originally thought it had to do with CRLF vs LF but changing those didn't affect anything. This builds locally fine with the "docker compose up" command.

my docker-compose.yml is the following

version: '3'
services:
  app1:
    build: 
      context: ./test/app1
  app2:
    build: ./test/app2
    ports:
      - "3306:3306"

note: I have also tried this in the yaml file but similar errors.

  #- task: DockerCompose@0
  #  displayName: docker compose - Build services
  #  inputs:
  #    action: Build services
  #    azureSubscriptionEndpoint: <redacted>
  #    azureContainerRegistry: <redacted>
  #    containerregistrytype: Azure Container Registry
  #    dockerComposePath: '$(Pipeline.Workspace)/s/docker-compose.yml'
  #    #dockerComposeFile: docker-compose.yml
  #    projectName: aakriti-test
  #    qualifyImageNames: true
  #    additionalImageTags: $(Build.BuildId)
  #    dockerComposeFileArgs: |
  #      firstArg=$(firstArg)
  #      secondArg=$(secondArg)

Upvotes: 0

Views: 3667

Answers (1)

Lucas Bazetto
Lucas Bazetto

Reputation: 647

The 127 is related to not found.

Might be related to your dockerComposePath? I'm not sure if you need to provide the /s after the $(Pipeline.Workspace).

  - task: DockerCompose@0
    displayName: 'Start docker compose'
    inputs:
      containerregistrytype: 'Container Registry'
      #dockerComposePath: '$(Pipeline.Workspace)/s/docker-compose.yml' If you remove the path the current work directory will be used
      dockerComposeFile: 'docker-compose.yml'
      action: 'Run a Docker Compose command'
      dockerComposeCommand: 'up -d'

If it doesn't work, I would try a PowerShell task just be sure that everything is ok with the CRLF like you said, something like:


  - task: PowerShell@2
    displayName: 'Docker compose'
    inputs:
      targetType: 'inline'
      script: 'docker-compose up -d'

Upvotes: 1

Related Questions