Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
vertical format for docker ps
export FORMAT="ID\t{{.ID}}\nNAME\t{{.Names}}\nIMAGE\t{{.Image}}\nPORTS\t{{.Ports}}\nCOMMAND\t{{.Command}}\nCREATED\t{{.CreatedAt}}\nSTATUS\t{{.Status}}\n"
// usage:
docker ps --format="$FORMAT"
@wzulfikar

This comment has been minimized.

Copy link
Owner Author

@wzulfikar wzulfikar commented Nov 1, 2016

using-sub-to-create-docker-ps-format

@shubhamoy

This comment has been minimized.

Copy link

@shubhamoy shubhamoy commented Jan 9, 2018

Thanks a lot. It works without the quotes as well docker ps --format=$FORMAT

@Luitame

This comment has been minimized.

Copy link

@Luitame Luitame commented May 21, 2018

Thanks! This helped me so much, because my screen it's in vertical align.

@vasuki1184

This comment has been minimized.

Copy link

@vasuki1184 vasuki1184 commented Dec 24, 2019

Thanks!! It's worked

@SandeepN97

This comment has been minimized.

Copy link

@SandeepN97 SandeepN97 commented Dec 12, 2020

I tried the same command but it doesn't work. I get error
C:\Users\DEADVILLA>export FORMAT="ID\t{{.ID}}\nNAME\t{{.Names}}\nIMAGE\t{{.Image}}\nPORTS\t{{.Ports}}\nCOMMAND\t{{.Command}}\nCREATED\t{{.CreatedAt}}\nSTATUS\t{{.Status}}\n"
'export' is not recognized as an internal or external command,
operable program or batch file.

@wzulfikar

This comment has been minimized.

Copy link
Owner Author

@wzulfikar wzulfikar commented Dec 12, 2020

Hey @SandeepN97, seems like you're not using shell and thus, it can't understand the export command. I assume you were on Windows and using PowerShell to run the command. If that's true, then yes, PowerShell doesn't understand export command. Instead, you can try run the command in git bash or wsl.

@SandeepN97

This comment has been minimized.

Copy link

@SandeepN97 SandeepN97 commented Dec 12, 2020

@wzulfikar

This comment has been minimized.

Copy link
Owner Author

@wzulfikar wzulfikar commented Dec 12, 2020

What you create inside container is not necessarily visible to your host machine unless you mount the volume from container to host.

For example, if you run your container with docker run --volume /tmp/nginx:/var/log/nginx nginx, files that you create and put inside /var/log/nginx in container will also be visible to /tmp/nginx in host (and vice versa). This is because you added the --volume option.

Check this article from DO to read more: https://www.digitalocean.com/community/tutorials/how-to-share-data-between-the-docker-container-and-the-host

If you need more, you can use "docker mount volume" as query for your Google search. Then you can dig more from there.

@SandeepN97

This comment has been minimized.

Copy link

@SandeepN97 SandeepN97 commented Dec 12, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment