docker container logging on host via volumes

Pablo Fernandez picture Pablo Fernandez · Mar 30, 2015 · Viewed 10.9k times · Source

I'm trying to have my container log into /var/log/app, a directory on the host machine. Unfortunately, changes made in the container are not being persisted, for example:

1 - start a container

sudo docker run -v /var/log/app --entrypoint bash -t -i b18bf31c48d5

2 - echo some file

echo "foo" > /varlog/app/foo.txt

3 - exit the container

4 - go check /var/log/app for foo.txt

it's not there.

Any idea why this happens?

Answer

Pablo Fernandez picture Pablo Fernandez · Mar 31, 2015

The problem was with the -v flag, this seems to make it work:

sudo docker run -v /var/log/app:/var/log/app:rw --entrypoint bash -t -i b18bf31c48d5