Before deploying a service, docker-orchestrate decides whether to pull the image from a registry. The pull policy controls this behavior. Getting this right matters because pulling always adds deployment time, but skipping pulls means you might deploy an outdated image.
The effective pull policy is determined in this order:
- If the
--pullCLI flag is specified, it takes precedence - Otherwise, the service's
pull_policyfrom the compose file is used - If neither is set, the default is
missing
| Value | Behavior |
|---|---|
always |
Always pull the image before deploying. A docker compose pull runs before the rolling update to download the image once upfront. |
missing |
Only pull if the image is not already present locally. This is the default. |
never |
Never pull. The image must already be available locally. |
build |
Build the image from a Dockerfile instead of pulling. Sets pull to never and runs docker compose build. Requires a build section in the service definition. |
The compose spec value if_not_present is treated as missing. The compose spec value refresh is not supported and produces an error.
Set pull policy in the compose file:
services:
web:
image: myapp:latest
pull_policy: alwaysOverride from the command line:
docker orchestrate deploy --pull always
docker orchestrate deploy --pull missing webUse the --build flag or pull_policy: build to build images from a Dockerfile before deploying. Building is useful in development or CI environments where you want to deploy from source rather than a pre-built image.
services:
web:
build:
context: .
dockerfile: Dockerfile
pull_policy: build- The
--buildCLI flag triggersdocker compose buildfor services with abuildsection - The
--buildflag is silently ignored for services without abuildsection pull_policy: buildwithout abuildsection produces an error--buildcan be combined with--pull-- they are independent concerns- When building, the pre-pull step is skipped since the image is built locally
- The
--buildflag also bypasses config hash comparison for services with abuildsection, since the image content may have changed
Every time a service is built, Docker Compose tags the resulting image (<project>-<service> by default, or the service's image: value) and records com.docker.compose.project and com.docker.compose.service labels in the image. When you redeploy, the new build takes over the tag and the previous image is left behind -- either untagged (dangling) or, when the image tag changes between deploys, orphaned under its old tag. Over many redeploys these leftover images accumulate and consume disk space.
The image prune command reclaims them:
docker orchestrate image prune
docker orchestrate image prune -p myproject
docker orchestrate image prune --dry-runHow it works:
- It keeps the image currently referenced by each service in the compose file (including services disabled by an inactive profile).
- It removes every other image carrying this project's
com.docker.compose.projectlabel. Because only images built by Compose carry that label, pulled base images and images from other projects are never touched. - Images still in use by a container -- for example, an old replica draining during a rolling update -- are skipped rather than force-removed.
- Pass
--dry-runto print which images would be removed without removing them.
The command reads the compose file to determine which images are current, so run it with the same -f/-p/--profile options you deploy with.
Pass --prune-images to deploy to prune leftover images automatically after a successful deploy:
docker orchestrate deploy --build --prune-imagesPruning runs only after the deploy succeeds. A prune failure is logged as a warning and does not fail the deploy.
- Command Reference --
--pull,--build, andimage pruneflag details - Deployment Configuration -- how config hash comparison interacts with
--buildand--pull always - Volumes -- anonymous volume warnings during rolling updates