I’ve been working quite a bit lately on a secure deletion tool for Docker containers. Here are a few notes on basic delete methods, without security, which hints at the problem.
- List all current containers
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e72211164489 hello-world "/hello" About a minute ago Exited (0) About a minute ago ecstatic_goodall 927e4ab62b82 hello-world "/hello" About a minute ago Exited (0) About a minute ago naughty_pasteur d71ff26dbb90 hello-world "/hello" 4 minutes ago Exited (0) 4 minutes ago hungry_wozniak 840279db0bd7 hello-world "/hello" 5 minutes ago Exited (0) 5 minutes ago lonely_pare 49f6003093eb hello-world "/hello" 25 hours ago Exited (0) 25 hours ago suspicious_poincare 6861afbbab6d hello-world "/hello" 27 hours ago Exited (0) 26 hours ago high_carson 2b29b6d5a09c hello-world "/hello" 3 weeks ago Exited (0) 3 weeks ago serene_elion
$ docker ps -a | grep “weeks”
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2b29b6d5a09c hello-world "/hello" 3 weeks ago Exited (0) 3 weeks ago serene_elion
$ docker ps -a | grep ‘ago’ | awk ‘{print $1}’
e72211164489 927e4ab62b82 d71ff26dbb90 840279db0bd7 49f6003093eb 6861afbbab6d 2b29b6d5a09c
$ docker ps -a | grep ‘ago’ | awk ‘{print $1}’ | xargs
e72211164489 927e4ab62b82 d71ff26dbb90 840279db0bd7 49f6003093eb 6861afbbab6d 2b29b6d5a09c
$ docker ps -a | grep ‘hours’ | awk ‘{print $1}’ | xargs -r -p docker rm
docker rm 49f6003093eb 6861afbbab6d ?...
Press y to delete, n to cancel