aws-codebuild-run-build icon indicating copy to clipboard operation
aws-codebuild-run-build copied to clipboard

Codebuild not recognizing Docker commands

Open twigs67 opened this issue 5 years ago • 2 comments

Hello,

Initially, I was receiving an exit error 125, but now I'm receiving an error of 1. Both cases, it seems that CodeBuild isn't recognizing one or more Docker commands or arguments.

This is the current error:


[Container] 2020/08/19 22:15:32 Running command docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .
--
41 | "docker build" requires exactly 1 argument.
42 | See 'docker build --help'.

My buildspec.yml is straightforward:

version: 0.2

phases:
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
  build:
    commands:
      - echo Build started on `date`
      - echo Building the Docker image...
      - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .
      - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker image...
      - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG

Image: aws/codebuild/standard:3.0 Privileged: True Environment Type: Linux

Any idea what the issue might be? I couldn't find any mention of this error in the troubleshooting docs

twigs67 avatar Aug 19 '20 22:08 twigs67

@twigs67 did you find any solution, I am getting the same error in the code build.

dawood76 avatar Apr 28 '21 07:04 dawood76

"docker build" requires exactly 1 argument

The problem lies in this line:

docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .

One of those variables has a space in it. You can fix this by quoting them. To replicate this error locally:

docker build -t meh hi-there .

This is not an issue with this action.

fearphage avatar Aug 05 '21 15:08 fearphage