skip to Main Content

We have an automatic deploy system so whenever someone pushes something on the main branch, a new docker container is created and the old one destroyed.

Naturally, all logs are no longer accessible for the old container at that time.

Is it possible to do something like, before the old container is destroyed, copy all the logs to a location, destroy the container and start up a new one?

2

Answers


  1. Use a volume, store the logs there. You could also try and change log drivers: https://docs.docker.com/config/containers/logging/configure/

    Login or Signup to reply.
  2. As json and text container logs are stored in the container path, they do have the very desirable property that when the container is cleaned up, so are they.

    So, your options are:

    1. Don’t clean up the containers until you no longer need the logs
    2. Use a tool like promtail to forward the logs to elasticsearch or loki for later examination in Grafana
    3. Use one of dockers built in log drivers to forward logs to a persistent log sink: one of awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search