You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a service has pull_policy: build, I would expect that its image would never be pulled. However docker-compose up and create will try to pull it the image doesn't exist, and then build it and tag the built image on top of the pulled image.
Steps to reproduce the issue:
Have a docker-compose.yml with a service with an image name, build context, and pull_policy: build
Ensure that the named image doesn't exist
Run docker-compose create or up
$ docker pull hello-world
$ docker images
...
hello-world latest feb5d9fea6a5 10 months ago 13.3kB
...
$ docker rmi hello-world
$ docker images | grep feb5d9fea6a5
$ # nothing, this is normal
$ cat > Dockerfile << EOF
FROM alpine
RUN echo
CMD ["echo", "I am not hello-world"]
EOF
$ cat > docker-compose.yml << EOF
services:
hello-world:
image: hello-world
build: .
pull_policy: build
EOF
$ docker-compose up
[+] Running 2/2
⠿ hello-world Pulled 2.7s
⠿ 2db29710123e Pull complete 0.6s
[+] Building 0.1s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 87B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 0.0s
=> CACHED [1/2] FROM docker.io/library/alpine 0.0s
=> [2/2] RUN echo 0.5s
=> exporting to image 0.4s
=> => exporting layers 0.4s
=> => writing image sha256:9048e15af052267db498ed68a56cac4a6a0ee32810155b3cfb9829cf5819140a 0.0s
=> => naming to docker.io/library/hello-world 0.0s
[+] Running 2/2
⠿ Network testcase_default Created 0.0s
⠿ Container testcase-hello-world-1 Created 0.1s
Attaching to testcase-hello-world-1
testcase-hello-world-1 | I am not hello-world
testcase-hello-world-1 exited with code 0
$ docker images | grep hello-world
hello-world latest 9048e15af052 About a minute ago 5.52MB
hello-world <none> feb5d9fea6a5 10 months ago 13.3kB
$ # our built image is here and tagged latest, which is normal
$ # but the image from docker hub, that we deleted earlier, has been pulled again
Describe the results you received:
The named image is downloaded from the repo before being built locally.
Describe the results you expected:
The repo is never contacted and the image is built locally.
Description
If a service has
pull_policy: build
, I would expect that its image would never be pulled. Howeverdocker-compose up
andcreate
will try to pull it the image doesn't exist, and then build it and tag the built image on top of the pulled image.Steps to reproduce the issue:
pull_policy: build
docker-compose create
orup
Describe the results you received:
The named image is downloaded from the repo before being built locally.
Describe the results you expected:
The repo is never contacted and the image is built locally.
Output of
docker compose version
:Output of
docker info
:The text was updated successfully, but these errors were encountered: