Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker container logging on host via volumes

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?

like image 262
Pablo Fernandez Avatar asked Sep 02 '25 10:09

Pablo Fernandez


1 Answers

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

like image 168
Pablo Fernandez Avatar answered Sep 04 '25 23:09

Pablo Fernandez