Docker_(container_engine)_logo

Docker – Useful commands

Here are few useful commands for Docker which I am using. So I summarized them here:

Show only IDs of running docker containersdocker ps -a -q
Stop all docker containersdocker stop $(docker ps -a -q)
Remove all docker containersdocker rm $(docker ps -a -q)
Show only IDs of all docker imagesdocker images -q
Remove all docker imagesdocker rmi $(docker images -q)
Show docker client (server) versiondocker version -f {{.Client.Version}}
docker version -f {{.Server.Version}}
Show docker stats for running containersdocker stats
Show docker stats for running containers with container names instead of container IDdocker stats $(docker ps --format={{.Names}})

How to get another part of docker version?

You can get everything from docker version result which looks like this:

Client:
Version:      1.12.1
API version:  1.24
Go version:   go1.7
Git commit:   23cf638
Built:        
OS/Arch:      darwin/amd64

Server:
Version:      1.12.6
API version:  1.24
Go version:   go1.6.4
Git commit:   78d1802
Built:        Wed Jan 11 00:23:16 2017
OS/Arch:      linux/amd64

And then call docker version -f {{.Part.Info}}  where Part is Client or Server value (block of information from version command) and Info replace with certain which you need.

Aleš Laňar
Senior Engineer Software ve společnosti CA Technologies

Leave a Reply

Your email address will not be published. Required fields are marked *