You can also use the --format option for docker ps to set a custom template. All of this depends on what you want to do. If you want to clean up images, I suggest working with docker images directly.
Awesome !
This is what exactly I wanted. Hoping I am rigjt track.
jim@jim-beam-VirtualBox:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f529b3f6e18b centos "/bin/bash -c 'while " 9 seconds ago Up 9 seconds jolly_mirzakhani
34d543c5bd8c centos "/bin/bash -c 'while " 10 seconds ago Up 10 seconds reverent_hypatia
85d2859bd99d centos "/bin/bash -c 'while " 11 seconds ago Up 11 seconds tender_hypatia
9b2d867b0b57 centos "/bin/bash -c 'while " 13 seconds ago Up 12 seconds gloomy_bhaskara
c1380986824c centos "/bin/bash -c 'while " 15 seconds ago Up 15 seconds tender_mccarthy
3ba112a480cc centos "/bin/bash -c 'while " 11 minutes ago Up About a minute drunk_cori
jim@jim-beam-VirtualBox:~$ docker ps --format ‘{{.Image}}’
centos
centos
centos
centos
centos
centos
jim@jim-beam-VirtualBox:~$ docker ps --format ‘{{.Names}}’
jolly_mirzakhani
reverent_hypatia
tender_hypatia
gloomy_bhaskara
tender_mccarthy
drunk_cori
jim@jim-beam-VirtualBox:~$
Therefore I can write a shell script to manage these applications. Either stop/start or even delete them.
If I want to delete the image I would do with
docker rmi correct?
Can you provide me an example of custom template? I couldn’t get that. Please bear with me as I am still learning. Apologies in advance for silly questions
If you just need to clean all containers, the docker ps -aq | xargs docker rm -v notation is a bit easier in my opinion (I usually use a subshell, i.e. docker rm $(docker ps -aq), but they’re practically the same). The format option comes in handy if you want to do something more flexible. The argument passed to the flag is a Golang text/template.