skip to Main Content

I am trying to run a code pipeline with github as the source, codeBuild as the builder and elastic beanstalk as the server infrastructure. I am using a docker image amazonlinux:2018.03 which works perfectly locally but during the codebuild in the pipeline i get the following error:

docker-compose: command not found

I have tried to install docker, docker-compose etc. but it keeps giving me this error. I’ve set the build to use a file buildspec.yaml:

version: 0.2
phases:
  install:
    commands:
        - echo "installing"
        - sudo yum install -y yum-utils 
        - sudo yum-config-manager  --add-repo https://download.docker.com/linux/centos/docker-ce.repo  
        - sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
        - sudo chmod +x /usr/local/bin/docker-compose
        - sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose 
        - docker-compose --version
  build:
    commands:
        - bash compose-local.sh

compose-local.sh:

#!/bin/bash
sudo docker-compose up

I have tried for a couple of days. And i am not sure if i am overseeing something with codeBuild i dont know?

2

Answers


  1. Run /usr/local/bin/docker-compose up instead.

    Login or Signup to reply.
  2. If using Ubuntu 2.0+ or Amazon Linux 2 image, we need to specify docker as the runtime-versions in install phase at buildspec.yml file, e.g.:

    version: 0.2
    phases:
      install:
        runtime-versions:
          docker: 18
      build:
        commands:
          - echo Build started on `date`
          - echo Building the Docker image with docker-compose...
          - docker-compose -f docker-compose.yml build 
    

    Also please make sure to enable privilege mode: https://docs.aws.amazon.com/codebuild/latest/userguide/create-project.html#create-project-console

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