1

I have a docker swarm stack and an application that run various docker containers to perform certain services. Sometimes those services take 10 minutes, some times, 3 seconds.

Looking for a solution to be able to read the docker logs from all of those services. For the containers that run longer, it can be easily achieved with docker log xxx but if the container starts up and dies shortly after, I can't do the same.

Appreciate any ideas on how I can log logs of all containers that start and stop. docker events don't get me any info.

d123
  • 117
  • 5

1 Answers1

1

Consider using a different logging driver, so that logs are persistently stored. The default, json-file, does not keep logs after containers are deleted. If you are using Docker CE, switch to journald and you can view Docker logs in the systemd journal (and syslog, if you have journal entries copied to syslog as most people do) as well as with docker logs. You have more logging options with Docker Enterprise, which are listed on Docker's web site, or you can configure systemd-journald to export logs to a wide variety of external destinations.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • At least on my system (Ubuntu 18 server) the default logs are persisted after the container is stopped. Only after I remove the container I cannot access them anymore. – Juraj Martinka Jul 08 '20 at 04:03
  • @JurajMartinka Short lived one time containers are usually started with the `--rm` option, which automatically deletes the container after it exits. – Gerald Schneider Jul 08 '20 at 08:22
  • That's a good point but I appreciate you updated your answer to be more precise :). – Juraj Martinka Jul 09 '20 at 04:20