Skip to content

[BUG] "docker compose ls" fails when some container lack label #10314

@hzqmwne

Description

@hzqmwne

Description

Currently check for "docker compose ls" seems too strict, and makes it fail easily and outputs nothing except an error message.
A better way maybe try to do "ls" on good containers as much as possible, and only skip bad containers.

For example,
when there are some container created by docker stack deploy or old v1 docker-compose,"docker compose ls" will fail because some label absents.

Below are two common scene that will cause failure

Steps To Reproduce

system: Ubuntu 22.04.2
docker version: 23.0.1 (docker-ce from https://download.docker.com/linux/ubuntu)
docker compose verison: v2.16.0 (docker-compose-plugin from https://download.docker.com/linux/ubuntu)
docker-compose version (deprecated v1 python version): 1.24.0 (docker-compose from https://pypi.org/project/docker-compose/)


First scene: combination use docker compose up and docker stack deploy

starts from Dockerfile:

FROM ubuntu:22.04

CMD ["sleep", "infinity"]

and compose.yaml:

services:
  sleep:
    build: .
    image: sleep
    init: true
  1. set docker repo, then run apt-get install docker-ce docker-compose-plugin
  2. docker swam init
  3. docker compose build
  4. docker stack deploy -c compose.yaml sleep
  5. docker compose up -d

now all containers running well, but if run docker compose ls command now, it will complain No label "com.docker.compose.project.config_files" set on container "<containerid>" of compose project


Second scene: combination use docker compose up (v2) and docker-compose up (very old version of v1)
(for example, there is a server running some compose service starts by very old v1 docker-compose, and later migrate to v2 docker compose

start from docker-compose.yml:

version: '3'

services:
  sleep:
    image: ubuntu:22.04
    command: ["sleep", "infinity"]
  1. set docker repo, then run apt-get install docker-ce docker-compose-plugin
  2. set python venv, then run pip3 install 'docker-compose==1.24.0'
  3. docker pull ubuntu:22.04
  4. docker-compose up -d

now container running well, but if run docker compose ls command now, it will complain No label "com.docker.compose.project.config_files" set on container "<containerid>" of compose project

Compose Version

# docker compose version
Docker Compose version v2.16.0
# docker-compose version
docker-compose version 1.24.0, build 0aa5906
docker-py version: 3.7.3
CPython version: 3.10.6
OpenSSL version: OpenSSL 3.0.2 15 Mar 2022

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.16.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
  scan: Docker Scan (Docker Inc.)
    Version:  v0.23.0
    Path:     /usr/libexec/docker/cli-plugins/docker-scan

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 16
 Server Version: 23.0.1
 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: 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: active
  NodeID: <hide>
  Is Manager: true
  ClusterID: <hide>
  Managers: 1
  Nodes: 1
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: <hide>
  Manager Addresses:
   <hide>:2377
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2456e983eb9e37e47538f59ea18f2043c9a73640
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.19.0-32-generic
 Operating System: Ubuntu 22.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.797GiB
 Name: <hide>
 ID: <hide>
 Docker Root Dir: /var/lib/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?

Expected solution:
For first scene, docker compose or docker stack should set label correctly
For second scene2, if there are some containers created by old version docker-compose and not well-labeled, new version docker compose should just skip/warning on them, and still list other well-labeled contaners instead of giving up

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