Getting a container ID from inside a container proves difficult. The file /proc/self/cgroups contains it, but is a symbolic link constantly changing, and io/file has not proven to work for me. This works:
You can also set a --cid-file
option when using docker run
, making things easier, however to my knowledge this option is not available with docker-compose