dotcloud/docker — pull request #1159 by unclejack (2013-07-08 08:12:17+00:00)
Title: add support for container ID files (a la pidfile)

This PR adds support for writing container ID files. Right now, the container ID files aren't automatically deleted so that they can be read by a third party tool.
The code which handles the container ID file in CmdRun is similar to how createPidFile (on purpose).

This comes in handy when running something attached like this to get the whole output in realtime:
```
$ docker run mydbimage /start.sh
output
```
How can we get the container ID in this case? `docker ps -q -l` could help, but what if other containers are popping up at the same time?

Let's try again with container ID file:
```
$ docker run -cidfile /var/containers/mydbinstance1 /start.sh
output
# from another terminal
$ mydbinstance=$(cat /var/containers/mydbinstance1)
$ echo $mydbinstance
bba1d25eb1e0
```

The container ID files aren't deleted automatically when containers exit, they're only closed.
This PR is also meant to be an open discussion.