-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Description
TL;DR:
- Please support
--quiet-buildequivalent to--quiet-pullifpull_policy: buildis behaving as intended. - Consider deriving an image name fallback from
build.tagswhen present, instead of only concatenating project + service names.
Similar to this issue which appears to have been resolved with docker compose run --quiet-pull, it would be nice if there was an equivalent for services that build locally instead of pull.
Doc reference:
- https://docs.docker.com/reference/compose-file/build/#using-build-and-image
- https://docs.docker.com/reference/compose-file/build/#tags
- https://docs.docker.com/reference/compose-file/services/#image
- https://docs.docker.com/reference/compose-file/services/#pull_policy
If the service has no image field, it'll derive one for the image name to be built from the compose project + service names. Build tags are always append, so if you did not want the implicit image name, you would need to provide an explicit one via image.
Doing so will have the pull_policy by default try to pull that remotely if there is no existing image. If there is an existing image, then there is no redundant output.
Steps To Reproduce
name: my-project
services:
my-service-a:
build:
dockerfile_inline: |
FROM alpine
my-service-b:
image: localhost/my-service-b
build:
dockerfile_inline: |
FROM alpine
my-service-c:
image: localhost/my-service-c
pull_policy: build
build:
dockerfile_inline: |
FROM alpinemy-service-abuilds the image asmy-project-my-service-amy-service-bhas a once off warning that the pull failed if the name doesn't resolve remotely:! my-service-b Warning Get "http://localhost/v2/": dial tcp [::1]:80: connect: connection refused
However for my-service-c where a local build is enforced via pull_policy: build, but the image is tagged with a customized name (grouping under localhost/ for example), this always results in noise for building the image even when there is no context change:
# Could also be: docker compose run --rm my-service-c
$ docker compose up my-service-c
[+] Building 0.2s (6/6) FINISHED docker:default
=> [my-service-c internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 116B 0.0s
=> [my-service-c internal] load metadata for docker.io/library/alpine:latest 0.0s
=> [my-service-c internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [my-service-c 1/1] FROM docker.io/library/alpine:latest 0.0s
=> [my-service-c] exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:b37192f1609b544629b31b920b5ed3925fa283ffe1af7f714e4a874a5362493f 0.0s
=> => naming to localhost/my-service-c 0.0s
=> [my-service-c] resolving provenance for metadata file 0.0sThat seems redundant? It either should not be output, or some option akin to --quiet-pull should be supported to omit that noise.
Meanwhile:
my-service-bconfig is valid to use if you're sure the image name chosen won't resolve remotely.- The derived image name for
my-service-ais not really desirable. I'm not sure how likely it is someone would depend upon that and explicitbuild.tags, so ifbuild.tagswere specified perhaps the fallback image name could preferbuild.tags[0](first tag), and thuspull_policy: buildwould not be necessary while also avoiding the noise output demonstrated viamy-service-c.
Compose Version
Docker Compose version 2.30.3
I checked release notes since this version and nothing suggests the output/behaviour would differ.
Docker Environment
Client:
Version: 27.3.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: 0.18.0
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: 2.30.3
Path: /usr/libexec/docker/cli-plugins/docker-compose
# Omitted some lines:
Server:
Server Version: 27.3.1
Storage Driver: overlay2
Cgroup Driver: systemd
Cgroup Version: 2
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: /usr/bin/tini-static
containerd version: 3.fc41
runc version:
init version:
Kernel Version: 6.11.7-300.fc41.x86_64
Operating System: Fedora Linux 41 (Server Edition)
OSType: linux
Architecture: x86_64
Insecure Registries:
127.0.0.0/8
Anything else?
No response