Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] docker compose ps --format json no longer returns an array in 2.21.0 #10958

Closed
unikitty37 opened this issue Sep 1, 2023 · 9 comments
Closed
Labels

Comments

@unikitty37
Copy link

Description

The release notes for 2.21.0 state "Changed docker compose ps and docker compose ps --format=json output to align with Docker CLI."

However, in prior versions, the result was a valid JSON array. 2.21.0 returns individual objects, one after the other, with no [ … ] wrapper. This doesn't seem to be valid JSON.

Although jq can handle this, Ruby's JSON.parse rejects it as invalid; I've not tried other parsers.

Was this intended?

Steps To Reproduce

  1. With any Compose project, run docker compose up -d.
  2. Run docker-compose ps --format json.

Versions before 2.21.0 will return an array of objects; version 2.21.0 will return sequential objects, separated only by a new line.

Compose Version

% docker compose version
Docker Compose version v2.21.0
% docker-compose version
Docker Compose version v2.21.0

Docker Environment

Client:
 Version:    24.0.5
 Context:    orbstack
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.1
    Path:     /Users/username/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.21.0
    Path:     /Users/username/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/username/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.20
    Path:     /Users/username/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.6
    Path:     /Users/username/.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/username/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/username/.docker/cli-plugins/docker-scan
  scout: Command line tool for Docker Scout (Docker Inc.)
    Version:  0.20.0
    Path:     /Users/username/.docker/cli-plugins/docker-scout

Server:
 Containers: 22
  Running: 11
  Paused: 0
  Stopped: 11
 Images: 23
 Server Version: 24.0.5
 Storage Driver: overlay2
  Backing Filesystem: btrfs
  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: fe457eb99ac0e27b3ce638175ef8e68a7d2bc373
 runc version: 82f18fe0e44a59034f3e1f45e475fa5636e539aa
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.4.13-orbstack-00090-ga4cfdc88d4df
 Operating System: OrbStack
 OSType: linux
 Architecture: aarch64
 CPUs: 10
 Total Memory: 11.67GiB
 Name: orbstack
 ID: 437f17f3-56ac-4f55-ad12-6154b025c473
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  http://192.168.69.99:13588/
 Live Restore Enabled: false
 Product License: Community Engine
 Default Address Pools:
   Base: 192.168.215.0/24, Size: 24
   Base: 192.168.228.0/24, Size: 24
   Base: 192.168.247.0/24, Size: 24
   Base: 192.168.207.0/24, Size: 24
   Base: 192.168.167.0/24, Size: 24
   Base: 192.168.107.0/24, Size: 24
   Base: 192.168.237.0/24, Size: 24
   Base: 192.168.148.0/24, Size: 24
   Base: 192.168.214.0/24, Size: 24
   Base: 192.168.165.0/24, Size: 24
   Base: 192.168.227.0/24, Size: 24
   Base: 192.168.181.0/24, Size: 24
   Base: 192.168.158.0/24, Size: 24
   Base: 192.168.117.0/24, Size: 24
   Base: 192.168.155.0/24, Size: 24
   Base: 192.168.147.0/24, Size: 24
   Base: 192.168.229.0/24, Size: 24
   Base: 192.168.183.0/24, Size: 24
   Base: 192.168.156.0/24, Size: 24
   Base: 192.168.97.0/24, Size: 24
   Base: 192.168.171.0/24, Size: 24
   Base: 192.168.186.0/24, Size: 24
   Base: 192.168.216.0/24, Size: 24
   Base: 192.168.242.0/24, Size: 24
   Base: 192.168.166.0/24, Size: 24
   Base: 192.168.239.0/24, Size: 24
   Base: 192.168.223.0/24, Size: 24
   Base: 192.168.164.0/24, Size: 24
   Base: 192.168.163.0/24, Size: 24
   Base: 192.168.172.0/24, Size: 24
   Base: 172.17.0.0/16, Size: 16
   Base: 172.18.0.0/16, Size: 16
   Base: 172.19.0.0/16, Size: 16
   Base: 172.20.0.0/14, Size: 16
   Base: 172.24.0.0/14, Size: 16
   Base: 172.28.0.0/14, Size: 16

Anything else?

json_files.zip

This is occurring with OrbStack; Docker Desktop is still providing Docker Compose version v2.20.2-desktop.1, and is thus unaffected for now.

@glours
Copy link
Contributor

glours commented Sep 1, 2023

Hey @unikitty37
This is expected and mentioned in the v2.21.0 release notes. We aligned the docker compose ps format to the docker ps one, for more details see #10918

@unikitty37
Copy link
Author

Got it — thanks! I was reading the release notes at https://docs.docker.com/compose/release-notes/, which don't have links to the underlying tickets. Would it be worth explicitly mentioning this there?

@glours
Copy link
Contributor

glours commented Sep 1, 2023

Sure I'll open a PR to mention it there 👍

@unikitty37
Copy link
Author

Thanks!

@philBrown
Copy link

Doesn't this represent a breaking change, requiring a major version bump?

@tingstad
Copy link

tingstad commented Sep 7, 2023

Doesn't this represent a breaking change, requiring a major version bump?

It certainly broke several of our builds since GitHub recently updated its Ubuntu runner images to use 2.21.0.

@veaviticus
Copy link

veaviticus commented Sep 8, 2023

The docker compose docs (https://docs.docker.com/engine/reference/commandline/compose_ps/#format) also still claim the output is array-formatted JSON, instead of a jsonlines-esque format.
image

haines added a commit to cerbos/cerbos-sdk-ruby that referenced this issue Sep 12, 2023
haines added a commit to cerbos/cerbos-sdk-ruby that referenced this issue Sep 12, 2023
* chore(deps): Bump grpc from 1.57.0 to 1.58.0

Bumps [grpc](https://github.com/google/grpc) from 1.57.0 to 1.58.0.
- [Release notes](https://github.com/google/grpc/releases)
- [Changelog](https://github.com/grpc/grpc/blob/master/doc/grpc_release_schedule.md)
- [Commits](grpc/grpc@v1.57.0...v1.58.0)

---
updated-dependencies:
- dependency-name: grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump bundler from 2.4.13 to 2.4.19

Signed-off-by: Andrew Haines <haines@cerbos.dev>

* Handle breaking change to `docker compose ps` output format

docker/compose#10958

Signed-off-by: Andrew Haines <haines@cerbos.dev>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Andrew Haines <haines@cerbos.dev>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Haines <haines@cerbos.dev>
haines added a commit to haines/cerbos-sdk-javascript that referenced this issue Sep 12, 2023
haines added a commit to haines/cerbos-sdk-javascript that referenced this issue Sep 12, 2023
haines added a commit to haines/cerbos-sdk-javascript that referenced this issue Sep 12, 2023
haines added a commit to cerbos/cerbos-sdk-javascript that referenced this issue Sep 12, 2023
* Bump node from 20.5.1 to 20.6.1
* Bump npm from 9.8.1 to 10.1.0
* Drop support for Node.js 16
* Handle breaking change to `docker compose ps` output format
  docker/compose#10958
* Handle updated invalid argument error details in Cerbos 0.30

Signed-off-by: Andrew Haines <haines@cerbos.dev>
@Rikaelus
Copy link

Not to be a prick but Docker doing something misleading and wrong doesn't seem to me to be just cause to break what worked and turn valid JSON into invalid JSON. Nor should this be considered JSON format when it isn't, in fact, valid JSON.

This definitely pressed my "principle of the thing" button. This is the kind of command people have buried in codebases that are now broken -- codebases that might now have to compensate to support both to remain compatible with multiple Docker Compose versions on host machines.

@alexrosenfeld10
Copy link

I'm impacted by this as well. @unikitty37 at the very least you should reopen this until the docs are updated to show the no json array behavior.

joejordan added a commit to joejordan/letsencrypt-docker-compose that referenced this issue Jan 20, 2024
Docker prior to version 2.21.0 returned valid json when calling `docker-compose ps --format json`. Newer versions now return a series of json objects. This bugfix utilizes jq in the cli to fix the issue.

More info: docker/compose#10958
errpunk added a commit to errpunk/letsencrypt-docker-compose that referenced this issue Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants