Docker Compose Build Command
# docker compose build command
[Docker Command List](#)
* * *
The docker compose build command builds images for services according to the definitions in the docker-compose.yml file.
docker compose build builds images from the specified Dockerfile or build context and prepares containers for all services.
### Syntax
docker compose build [SERVICE...]
* **SERVICE** (optional): Specifies the name of the service to build. If not specified, images will be built for all services.
**OPTIONS:**
* `--no-cache`: Does not use cached layers during the build process, forcing the image to be built from scratch.
* `--pull`: Always attempts to pull the latest base image from the registry.
* `--build-arg`: Passes variables at build time (similar to Docker's `--build-arg` option).
* `--progress`: Specifies the progress style (`auto`, `plain`, `tty`) that affects how output is displayed.
* `--parallel`: Builds multiple service images in parallel to speed up the process.
* `--no-rm`: Retains intermediate containers if the build fails (by default, intermediate containers are deleted after success or failure).
### Examples
**1. Build images for all services**
docker compose build
Builds images for all services according to the configuration in docker-compose.yml.
**2. Build images for a specific service**
docker compose build web
Builds an image only for the web service.
**3. Build images without using cache**
docker compose build --no-cache
Forces Docker to build all images from scratch, without using previously built cached layers.
**4. Build from the latest base image**
docker compose build --pull
Ensures Docker pulls the latest base image instead of using the local image.
**5. Pass build variables**
docker compose build --build-arg NODE_ENV=production
Passes required variables at build time via --build-arg, such as passing the NODE_ENV environment variable.
* * Docker Command List](#)
AI thinking in progress...
[](#)(#)
(#)[](#)
[VolcEngine Coding Plan supports mainstream large models such as Doubao, GLM, DeepSeek, Kimi, MiniMax, etc., directly provided by the official source for stable and reliable performance. Configuration guide Β₯9.9/month, activate now](https://maas.xfyun.cn/modelSquare?ch=maas_lm_l2E)
YouTip