Docker-compose build --build-arg not working

The docs here: https://docs.docker.com/compose/reference/build/

Indicate that you can call docker-compose build with args…however it seems to be failing.

Usage: build [options] [--build-arg key=val...] [SERVICE...]

Options:
    --force-rm              Always remove intermediate containers.
    --no-cache              Do not use cache when building the image.
    --pull                  Always attempt to pull a newer version of the image.
    --build-arg key=val     Set build-time variables for one service.

What’s the error message? I was getting the same but apparently I was forgetting to pass the services I wanted to build. Like:

docker-compose build --build-arg SOME_ENV=hello web

However, I’m not sure how to run this for all services without specifying one by one.

2 Likes