[Bug]: Docker Compose deploy fails since v4.3.19 when images are built by a custom build command (pre-stop pull --ignore-buildable)
Description and Error Message
Since v4.3.19, Docker Compose deployments whose images are built on the server by a custom build command (and never pushed to a registry) fail right after a successful build.
Commit 361d5a3c8 (feat(deploy): pull compose images before stopping containers) added pull_docker_compose_images(), which runs docker compose pull --ignore-buildable before stopping the current deployment and fails the deploy if the pull fails.
--ignore-buildable only skips services that have a build: section. When the compose file only declares image: because the image is produced by the custom build command, compose treats it as a registry image and tries to pull it from Docker Hub. The image exists locally (it was just built), but the pull still fails and aborts the deployment:
Pulling & building required images.
[CMD]: ... DOCKER_BUILDKIT=1 docker buildx bake -f docker-bake.prod.hcl
...
#55 naming to docker.io/library/myapp:php-latest done
#59 naming to docker.io/library/myapp:caddy-latest done
Pulling image-based services before stopping the current deployment.
[CMD]: ... docker compose --env-file .../.env --project-name <uuid> --project-directory ... -f .../docker-compose.prod.yml pull --ignore-buildable
Image myapp:php-latest Pulling
Image myapp:caddy-latest Pulling
Image myapp:caddy-latest Error pull access denied for myapp, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Error response from daemon: pull access denied for myapp, repository does not exist or may require 'docker login'
Deployment failed: Command execution failed (exit code 1)
#4 app/Jobs/ApplicationDeploymentJob.php(811): App\Jobs\ApplicationDeploymentJob->pull_docker_compose_images()The exact same repository and configuration deployed fine on v4.3.18 the day before; nothing changed on our side.
This compose behaviour is intended upstream (docker/compose#8805, docker/compose#10123): a service without build: is expected to come from a registry unless pull_policy says otherwise.
Expected Behavior
- A successful custom build followed by the pre-stop pull does not fail the deployment when the image exists locally.
- Locally built images are not pulled from a registry at all.
- The pre-stop pull only fails the deployment for images that genuinely must come from a registry.
- The new containers start as they did on v4.3.18.
Steps to Reproduce
- Create a Docker Compose application with a custom build command, e.g.
docker build -t myapp:latest .(we usedocker buildx bake -f docker-bake.prod.hcl). - Use a compose file whose service references that local tag without a
build:section:services: app: image: myapp:latest - Deploy on v4.3.19.
- The build succeeds, then
pull --ignore-buildablefails withpull access deniedand the deployment is aborted.
Example Repository URL
No public repository; the minimal compose above reproduces it.
Coolify Version
v4.3.19 (auto-updated; latest release at the time of writing: v4.3.19)
Are you using Coolify Cloud?
Yes
Operating System and Version (self-hosted)
Linux aarch64 (not OS-specific: the failure comes from the compose pull command itself)
Additional Information
Workaround: add pull_policy: never to every service whose image is built locally. docker compose pull skips never and build policies (mustPull in pkg/compose/pull.go), and the compose build pack later starts with up -d, so the local image is used. Note that the build-server branch of start_by_compose_file() uses up --pull always, which would override never.
Possible fixes on the Coolify side (any of them):
- skip
pull_docker_compose_images()when a custom build command is configured, since images may be built outside compose; - run the pull with
--ignore-pull-failuresand letupfail later only if an image is really missing; - before pulling, skip services whose
imagealready exists locally (docker image inspect).
Many existing setups break silently on upgrade here, because on earlier versions these compose files never went through a pull.
Source: coollabsio/coolify