opdemand/deis-cookbook — pull request #40 by gabrtv (2013-12-04 18:54:09+00:00)
Title: Automatically remove container leftovers

Leverage the `-rm` flag in `docker run` to automatically clean up filesystem read/write layers and other container files. Container leftovers are now cleaned up automatically when performing a `deis scale web=0`:

```
root@ip-10-250-15-201:/var/lib/docker/containers# docker ps -a
ID IMAGE COMMAND CREATED STATUS PORTS
920cdeb80690 deis/buildstep:latest /bin/sh -c export HO 5 minutes ago Up 5 minutes 10008->10008
7e24e8c0a448 deis/buildstep:latest /bin/sh -c export HO 5 minutes ago Up 5 minutes 10005->10005
825f7a294d78 deis/buildstep:latest /bin/sh -c export HO 5 minutes ago Up 5 minutes 10004->10004
root@ip-10-250-15-201:/var/lib/docker/containers# ls -l
total 12
drwx------ 4 root root 4096 Dec 4 18:43 7e24e8c0a448b62fa222b6c8bfa4df900eb5935330b20edbac59aa71a3dfebed
drwx------ 4 root root 4096 Dec 4 18:43 825f7a294d78063ce67ba5a8bc6a749ccaf107ea028d1cdb1662f48f3e2ef5e4
drwx------ 4 root root 4096 Dec 4 18:43 920cdeb806908aa2a7db360167db8f4e75bb9208719eb36bb97d33fd420bf64f
root@ip-10-250-15-201:/var/lib/docker/containers# docker ps -a
ID IMAGE COMMAND CREATED STATUS PORTS
root@ip-10-250-15-201:/var/lib/docker/containers#
```