Skip to content

Instantly share code, notes, and snippets.

@wzulfikar
Last active March 14, 2024 13:36
Show Gist options
  • Star 41 You must be signed in to star a gist
  • Fork 19 You must be signed in to fork a gist
  • Save wzulfikar/f6f7dc8b9d6aa5bc207eaa31913201d8 to your computer and use it in GitHub Desktop.
Save wzulfikar/f6f7dc8b9d6aa5bc207eaa31913201d8 to your computer and use it in GitHub Desktop.
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"
@vasuki1184
Copy link

Thanks!! It's worked

@SandeepN97
Copy link

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
Copy link
Author

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
Copy link

SandeepN97 commented Dec 12, 2020 via email

@wzulfikar
Copy link
Author

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
Copy link

SandeepN97 commented Dec 12, 2020 via email

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