Reputation: 780
Suppose my application generate logs in a folder /app/logs/ . For convenience multiple log files are generated (based on different runtime contexts) for better monitoring. If I containerize my application using Docker, how can I access my logs generated at runtime in logs folder?
My application doesn't have a nohup type of logging and certainly
docker logs -f <container-id>
doesn't seem to work.
Upvotes: 0
Views: 922
Reputation: 74879
docker logs
will only show the stderr and stdout from the process you are running.
Containers work well with a centralised logging system as it fits with their ephemeral/scalable design. Use syslog, loggly, graylog, logstash, fluentd etc to push your docker logs over the network to a server. Access all your app and context logs in one location.
If that seems like too much...
You can access the logs directly from the host
docker exec <container-id> cat /apps/logs/context.log
You can log to a shared data volume
docker volume create logs
docker run -v logs:/apps/logs <image>
You can log to a host directory
docker run -v /apps/logs:/apps/logs <image>
Upvotes: 2