Skip to content

[Feature Request] Introduce either format or save option to Compose v2 to save images in a compose project as tar balls #9471

Open
@shantanoo-desai

Description

@shantanoo-desai

Description
Currently Docker Compose v2.5.0 provides a command call docker compose images which will list the images / containers within dedicated docker-compose.yml file.

There is currently no way to use these --format option alongside with e.g. docker compose images --format="{{.Repository}}:{{.Tag}}" in order to save the images as tarball.

A common usage pattern with Docker CLI would be:

docker save -o myStack.tar $(docker images --format "{{.Repository}}:{{.Tag}}")

The above however requires to have a host with only the dedicated container images. In most if not all cases, host machine have many container images which may not be required in the compose project.

A potential introduction of either docker compose images --format would be useful to pack the images into a tarball without having to remove other containers outside a dedicated project or provide docker compose save to achieve the same.

Steps to reproduce the issue:
Current method of creation of tar balls is:

docker save -o myStack.tar $(docker compose images -q)

This is a bit problematic, since -q only lists the Image IDs of the container. In situations where the tarball is loaded onto an offline machine with the dedicated docker-compose.yml file, upon triggering

$ docker load -i myStack.tar # will load the images but won't have names and version in them
$ docker compose up # will try to pull the images from hub because compose files have `name:version` in them

docker compose will try to pull images from the Hub, because as standard usage each image in a compose file is always mapped with a name:version as opposed to Image Hashes

Describe the results you expected:

by using docker compose save -o <tarballname>.tar one would be able to save the images

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker compose version:

Docker Compose v2.5.0

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2)
  compose: Docker Compose (Docker Inc., v2.5.0)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 15
  Running: 6
  Paused: 0
  Stopped: 9
 Images: 8
 Server Version: 20.10.14
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 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 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc version: v1.0.3-0-gf46b6ba
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.16.3-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 24.78GiB
 Name: docker-desktop
 ID: AM3A:EIDA:J3BS:FMN2:MZMR:3CBY:YHXN:US7Q:BIKM:7POA:WAGC:MRWX
 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
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions