Search code examples
dockerdocker-composeamazon-ecsamazon-ecr

Docker compose on ecr: ERROR: No such service: --build-arg


I try to pass arg into the docker build process in this command:

docker-compose -f .docker/docker-compose.ecr.yml build my-app --build-arg BUILD_VERSION=5.0.0

But I got error:

ERROR: No such service: --build-arg

According to the docs docker-compose have build-arg parameter.

The yml file:

version: '3'

services:
  my-app:
    image: 3144.dkr.ecr.us-east-2.amazonaws.com/my-app:latest
    build:
      context: ../
      dockerfile: ./.docker/Dockerfile

What can be the problem?


Solution

  • The services should be last in the command line.

    $ docker-compose build --help
    Usage: build [options] [--build-arg key=val...] [SERVICE...]
    

    So:

    $ docker-compose -f .docker/docker-compose.ecr.yml build --build-arg BUILD_VERSION=5.0.0 my-app