Skip to content

Conversation

@vCoRezZ
Copy link

@vCoRezZ vCoRezZ commented Mar 2, 2023

line of the output with the string "json"
docker ps --format "{{json .}}" does the described behaviour

how to verify:
run both commands and compare the output

line of the output with the string "json"
docker ps --format "{{json .}}" does the described behaviour

how to verify:
run both commands and compare the output
@vCoRezZ vCoRezZ requested a review from thaJeztah as a code owner March 2, 2023 19:51
@vCoRezZ
Copy link
Author

vCoRezZ commented Mar 2, 2023

don't know if i missed something, if my mr can't be merges could someone else fix this pls.

@thaJeztah
Copy link
Member

What version of Docker are you running? Is this on Docker Desktop? The json format option is a new addition on Docker Engine 23.0, which has not yet shipped with Docker Desktop. On Docker 23.0, this should work (both options should provide the same result); Here's the result on docker 23.0;

docker ps --format json
{"Command":"\"/docker-entrypoint.…\"","CreatedAt":"2023-03-02 20:59:19 +0000 UTC","ID":"30a73eea432e","Image":"nginx:alpine","Labels":"maintainer=NGINX Docker Maintainers \u003cdocker-maint@nginx.com\u003e","LocalVolumes":"0","Mounts":"","Names":"bar","Networks":"bridge","Ports":"80/tcp","RunningFor":"8 seconds ago","Size":"0B","State":"running","Status":"Up 8 seconds"}
{"Command":"\"/docker-entrypoint.…\"","CreatedAt":"2023-03-02 20:59:14 +0000 UTC","ID":"9124ad73c355","Image":"nginx:alpine","Labels":"maintainer=NGINX Docker Maintainers \u003cdocker-maint@nginx.com\u003e","LocalVolumes":"0","Mounts":"","Names":"foo","Networks":"bridge","Ports":"80/tcp","RunningFor":"13 seconds ago","Size":"0B","State":"running","Status":"Up 12 seconds"}.

docker ps --format "{{json .}}"
{"Command":"\"/docker-entrypoint.…\"","CreatedAt":"2023-03-02 20:59:19 +0000 UTC","ID":"30a73eea432e","Image":"nginx:alpine","Labels":"maintainer=NGINX Docker Maintainers \u003cdocker-maint@nginx.com\u003e","LocalVolumes":"0","Mounts":"","Names":"bar","Networks":"bridge","Ports":"80/tcp","RunningFor":"17 seconds ago","Size":"1.09kB (virtual 40.3MB)","State":"running","Status":"Up 17 seconds"}
{"Command":"\"/docker-entrypoint.…\"","CreatedAt":"2023-03-02 20:59:14 +0000 UTC","ID":"9124ad73c355","Image":"nginx:alpine","Labels":"maintainer=NGINX Docker Maintainers \u003cdocker-maint@nginx.com\u003e","LocalVolumes":"0","Mounts":"","Names":"foo","Networks":"bridge","Ports":"80/tcp","RunningFor":"22 seconds ago","Size":"1.09kB (virtual 40.3MB)","State":"running","Status":"Up 22 seconds"}

There is a small difference that we may have to document, as the json option does not by default set the --size option (some related discussion on that in #4057 and #4067)

/cc @laurazard

@vCoRezZ
Copy link
Author

vCoRezZ commented Mar 3, 2023

Yes, I tested it on Docker Desktop on the newest version. My bad for not testing on Docker 23. I just checked and it works for me on 23.0. I'll close this mr.

@vCoRezZ vCoRezZ closed this Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants