compose icon indicating copy to clipboard operation
compose copied to clipboard

[BUG] docker compose pulls every build parent container from upstream instead taking existing one from the local cache

Open Marco-Israel opened this issue 1 year ago • 1 comments

Description

Im Trying to build a container on top of an already pre-build base container. Docker build works fine, takes the pre-build one from the local cache and builds the extended container on top of it. Docker compose build ignores the local cached base version at every build and tries to pull (or checks at lest) this as an online upstream container. The build breaks because docker compose can not find it on docker hub.

Base : From Ubuntu   <-- was build successfully before and exists in the local cache
^
Sub:   From Base       <-- docker build takes the local reference and build the Sub as exacted.  docker-compose stop the build process because it only tries to search upstream for the base image wich is logical not available

What is needed to let docker compose build take the image from the local cache first of all? I played already with pull_policy=never/missing but without any effect solving the issue. Im running on Arch Linux 6.3.1-arch1-1

Note: In my configuration, the docker cache is not in the default path /var/lib docker, but on an external hdd while a symlink is pointing to the new location and/etc/docker/deamon.jsonholds the right location:

sudo ls -la /var/lib/docker
lrwxrwxrwx 1 root root 14 26. Jul 04:20 /var/lib/docker -> /log_cache_hdd/docker

cat  /etc/docker/daemon.json
{
    "dns": ["8.8.8.8"],
    "data-root": "/log_cache_hdd/docker",
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}

Steps To Reproduce

  1. reconfigure your /etc/docker/daemon.json
  2. Create a base container Dockerfile + docker-compose.yaml
  3. Create a second Docker file while the FROM entry refers the base imagename:tag
  4. run docker-compose build

Compose Version

tested with docker-compose and docker compose in versions on ArchLinux 6.3.1-arch1-1:

Docker Compose version v2.20.2
and
Docker Compose version v2.17.3

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.10.4
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.17.3
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 142
  Running: 2
  Paused: 0
  Stopped: 140
 Images: 143
 Server Version: 23.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 nvidia runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1fbd70374134b891f97ce19c70b6e50c7b9f4e0d.m
 runc version:
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.3.1-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.35GiB
 Name: ws
 ID: DZVJ:HIQQ:KAIZ:UCAP:SOBV:GHBW:RYBX:FIWZ:DECG:Q4BP:YOGW:P36J
 Docker Root Dir: /log_cache_hdd/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

Marco-Israel avatar Jul 27 '23 09:07 Marco-Israel

v2.17.3 is pretty old, please install a recent release so you run up-to-date builder client.

please also check with docker buildx ls the active builder you're using

last but not least, can you please attach your build log demonstrating docker compose build trying to pull base image ? (can use docker compose --progress=plain build to make this sequential and easier to capture)

  • check docker image inspect Base successfully report image being present in local store

ndeloof avatar Nov 29 '23 09:11 ndeloof