New:
[root@ip-172--37 etc]# docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
415ec042e613aa3b767302440776042f7f05bcaac323349b893539b045643c00
34bfc4c420c2b2546e4f09980536040e134c472a0369082531a924293f569e07
12691c6aed14d098255e234498d8c757d675bc8d45d6341b261ab882ab9e1422
f7296839421ac5d2fd8c9f43e68f3c8139d17bcc49d530da4cc2904d570b3b75
Total reclaimed space: 36.57MB
[root@ip-17-32-37 etc]#
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@ip-172-31-32-37 etc]# docker images prune
(for removing dangling and ununsed images).
[root@ip-172-31-32-37 etc]# docker image prune -a
WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
untagged: mattrayner/lamp:latest-1604
untagged: mattrayner/lamp@sha256:f354e15c4e3b4cc0808aafa46ceb30a7a61eadabcfcdd39087feaf3328e4305d
Total reclaimed space: 0B
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:
b569eae3b83eb3eb3aca08a94f553f2998badd559378e24933405fd06a808f16
0cc6019d1af28a64462199e0cfc9e5c937b819a3bf72e82a41005cb09ecc57f4
39ac8810b6d9dba5a68765f839bc94d6f2cdd620fe152e4c61fb49b2f7db493c
bef1ba8ec1425520343fc421e60179c3afa8a3eaaa69d56b9401dfd2712d2e78
1c13a3b07f2466bbbe5ed3cbc00f3d7e7addd8ca974a3fa10c14607143c62e6f
ee95981e0eff756d6007783b1a363aa663d7df42d219c76f408be55de9e9db8d
Total reclaimed space: 139.2MB
[root@ip-172-31-32-37 etc]#
root@docker:~# docker images | awk '{print $1 ":" $2}' | xargs docker rmi -f
Untagged: bibinwilson/jenkins-slave:latest
Untagged: bibinwilson/jenkins-slave@sha256:dda6abf1cda7aa9eb7bef44cb3f209c8cdf230dd988fd6d72d07ce829c26a36e
Deleted: sha256:a6c4332f1b747938c4593edcd243d529fde72315281aa5cfc029c775c0ff9f1d
Error response from daemon: invalid reference format: repository name must be lowercase
root@docker:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
root@docker:~#
root@docker:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7aec23b3448b a6c4332f1b74 "/bin/bash" 22 hours ago Exited (130) 22 hours ago happy_panini
1f3ba05d2bbd a6c4332f1b74 "/bin/bash" 22 hours ago Exited (0) 22 hours ago cranky_brahmagupta
fbb8f3c9d809 a6c4332f1b74 "/bin/bash" 22 hours ago Exited (0) 22 hours ago hardcore_keller
431297d54259 14f60031763d "/bin/bash" 26 hours ago Exited (0) 26 hours ago trusting_bardeen
root@docker:~#
root@docker:~# docker ps -a | awk 'NR>1'|awk '{print $1}' |xargs docker rm
7aec23b3448b
1f3ba05d2bbd
fbb8f3c9d809
431297d54259
root@docker:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@docker:~#
Another method:
# docker ps -a | awk 'NR>1' |awk '{print $1}' > rmcntid.out
# for i in `cat rmcntid.out` ; do docker rm $i ; done