docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.93k stars 5.22k forks source link

[BUG] Error response from daemon: lease "moby-image-sha256:<sha>": not found #10856

Closed eltbus closed 2 weeks ago

eltbus commented 1 year ago

Description

Stopped working after updating Docker Desktop.

docker compose up error that seems to reference a custom image (in my example 69c50130ce91).

docker images
REPOSITORY        TAG       IMAGE ID       CREATED         SIZE
myapi             latest    69c50130ce91   4 minutes ago   228MB
postgres          latest    8769343ac885   2 days ago      412MB
nginx             latest    89da1fb6dcb9   2 days ago      187MB
grafana/grafana   latest    d09b57894d6e   4 days ago      329MB
prom/prometheus   latest    3b907f5313b7   5 days ago      245MB

Yields the following error:

docker compose up -d
[+] Running 0/0
 ⠋ Container energy-dev-case-api-1  Creating                                                                                                                                      0.0s
Error response from daemon: lease "moby-image-sha256:69c50130ce91dd23d26c2e7f26bad9438d8ae9b57bdfe92c29480adbc7d7e4bb": not found

Steps To Reproduce

Replace api with custom image.

My compose.yaml

version: "3.8"

services:
  db:
    image: postgres:latest
    environment:
      POSTGRES_USER: ${postgres_username}
      POSTGRES_PASSWORD: ${postgres_password}
      POSTGRES_DB: ${postgres_dbname}
    healthcheck:
      test: ["CMD", "pg_isready", "-d", "${postgres_username}", "-U", "${postgres_username}"]
      timeout: 30s
      interval: 10s
      retries: 3
    networks:
      - my_network
    expose:
      - "5432"
    volumes:
      - ./data/db:/var/lib/postgresql/data

  api:
    image: myapi
    environment:
      POSTGRES_USER: ${postgres_username}
      POSTGRES_PASSWORD: ${postgres_password}
      POSTGRES_DB: ${postgres_dbname}
      POSTGRES_HOST: db
    expose:
      - "8000"
    networks:
      - my_network
    depends_on:
      - db

  nginx:
    image: nginx:latest
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    ports:
      - "80:80"
    networks:
      - my_network
    depends_on:
      - api

networks:
  my_network:
    driver: bridge

Compose Version

Docker Compose version v2.19.1

Docker Environment

Client:
 Version:    24.0.2
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.0
    Path:     /Users/eltbus/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.19.1
    Path:     /Users/eltbus/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/eltbus/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.20
    Path:     /Users/eltbus/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.6
    Path:     /Users/eltbus/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/eltbus/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/eltbus/.docker/cli-plugins/docker-scan
  scout: Command line tool for Docker Scout (Docker Inc.)
    Version:  0.16.1
    Path:     /Users/eltbus/.docker/cli-plugins/docker-scout

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 24.0.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version: v1.1.7-0-g860f061
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.49-linuxkit-pr
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 4
 Total Memory: 7.668GiB
 Name: docker-desktop
 ID: a30a4433-b945-4976-b2b6-737656736769
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

milas commented 1 year ago

How did you build the myapi image? Via docker build or another tool?

Is this reproducible? With different images or just this one?

Also, can you open the Docker Desktop Troubleshoot menu (from the 🐳 menu in the macOS menu bar), choose Get Support, wait for diagnostics, upload and then share the ID here?

If this is not a persistent issue, it might be something corrupted in Docker Desktop, so you could also try Clean / Purge Data from that same menu (take a diag first!) to reset Docker Desktop's VM -- you will lose all your local containers/images/volumes/etc! So make sure you don't have anything vital that's not backed up.

iainlbc commented 1 year ago

I was hitting this as well when building and attempting to start a container from the go client.

After downgrading I got a more helpful error message (thank you for reporting this so I downgraded docker desktop to 4.19):

Error: error creating: error: %!w(string=Error response from daemon: image with reference registry:latest was found but does not match the specified platform: wanted darwin/arm64, actual: linux/arm64/v8)

Then I was able to determine I was building with the wrong platform/arch for m1 and adjust to passing Platform: "linux/arm64/v8" when calling ImageBuild() and

&ocispec.Platform{
    Architecture: "arm64/v8",
    OS:           "linux",
 }

when calling ContainerCreate()

Long story short maybe your image is built for the wrong platform/architecture.

Seems like the error reporting for this case regressed somewhere in docker-desktop or its dependencies between 4.19 and the current latest stable

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 weeks ago

This issue has been automatically marked as not stale anymore due to the recent activity.

jhrotko commented 2 weeks ago

Closing this issue as this is 1 year old. If the error still persists please feel free to re-open this issue.