have an application running inside docker container. the application writes log messages into local log files. how can i make the log file persistent in case the docker container stops or crashes?
Since the container are run time entity ,when i stop the image my logs/data is gone.
Thanks, Sohan
You can do this using docker volumes:
https://docs.docker.com/userguide/dockervolumes/
For example:
docker run -v /var/log/docker:/var/log your-image
will mount the log directory on your local file system. You can also get much fancier, creating containers just for data. It's all explained in the above link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With