# docker compose build: Build Service Images

> How docker compose build works: building images for services with a build section, --no-cache, build args, and CI caching.

Source: https://latchkey.dev/learn/command-reference/docker-compose-build  
Updated: 2026-06-25

Build the images for services that define a build section.

docker compose build builds (or rebuilds) images for services with a build: config. This page covers no-cache, build args, and using BuildKit cache in CI.

## What it does

docker compose build builds images for services that specify build: (context/Dockerfile). Services with only image: are pulled, not built. It does not start anything - pair with docker compose up.

## Common usage

```Terminal
docker compose build
docker compose build --no-cache
docker compose build --build-arg NODE_ENV=production api
docker compose build --pull
```

## Common errors in CI

"services.api.build: context: no such file or directory" means the build context path in the compose file does not exist relative to the file - paths are relative to the compose file, not the cwd. A service with only image: cannot be built ("does not have a build section"). For CI cache, set the service build.cache_from or use docker compose build with a BuildKit builder.

## FAQ

### docker compose build: Build Service Images?

docker compose build builds (or rebuilds) images for services with a build: config. This page covers no-cache, build args, and using BuildKit cache in CI.

### What it does?

docker compose build builds images for services that specify build: (context/Dockerfile). Services with only image: are pulled, not built. It does not start anything - pair with docker compose up.

### Common errors in CI?

"services.api.build: context: no such file or directory" means the build context path in the compose file does not exist relative to the file - paths are relative to the compose file, not the cwd. A service with only image: cannot be built ("does not have a build section").

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
