Nidhi
Nidhi

Reputation: 233

AWS Build Project service docker-compose build command not working

I want to build docker images and push into ECR for that I have written below buildspect.yml file and build my project using AWS build project service. My buildspec.yml file is as below:

version: 0.2
 


phases:
  install:
    runtime-versions:
      docker: 18
    commands: 
      - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://localhost:2375 --storage-driver=overlay2&
      - timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
  pre_build:
   commands:
     - $(aws ecr get-login --no-include-email --region ${AWS_DEFAULT_REGION})
     - REPOSITORY_URI_SERVER=<accountnumber>.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${IMAGE_NAME}
  build:
    commands:
     - docker-compose build
  post_build:
    commands:
     - docker-compose push
    

While I do build using AWS build project service then I will get an error like:

ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
[Container] 2020/07/10 01:57:15 Command did not exit successfully timeout 15 sh -c "until docker info; do echo .; sleep 1; done" exit status 124
[Container] 2020/07/10 01:57:15 Phase complete: INSTALL State: FAILED
[Container] 2020/07/10 01:57:15 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: timeout 15 sh -c "until docker info; do echo .; sleep 1; done". Reason: exit status 124

Upvotes: 2

Views: 1596

Answers (1)

Nidhi
Nidhi

Reputation: 233

I have tried to write buildspect.yml file as below I have added an artifact tag in my file that is the place where my project build is a store.

  post_build:
    commands:
     - docker-compose push
     - printf '[{"name":"<name of container>","imageUri":"<path of your image"}]'   > imagedefinitions.json
     - cat imagedefinitions.json
   artifacts:
     files: imagedefinitions.json

I got success in it.

Upvotes: 2

Related Questions