How can I download docker logs from remote server easily ? I can pipe the logs to a file and then use scp
to download the file, but it's a bit cumbersome.
Do direct scp from the remote system. Use some log monitoring tools like Graylog or ELK so that you can stream your live container logs in browser. Use Container orchestration tool like kubernetes which shows all container logs in its console itself even if multiple remote nodes are present.
First of all, to list all running containers, use the docker ps command. Then, with the docker logs command you can list the logs for a particular container. Most of the time you'll end up tailing these logs in real time, or checking the last few logs lines.
By default, the Docker containers log files are stored in /var/lib/docker/containers/<containerId> dir.
Depends what you're trying to do.
If you're just trying to ship the logs off somewhere else for storage/auditing purpose, maybe consider a different logging driver like the syslog or splunk drivers.
However, if you just want to copy them locally for debugging purposes, the json-file
driver will store the files in /var/lib/docker/containers/<container-id>/<container-id>-json.log
You can simply scp
that file down and get all the logs you need.
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