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.


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.

  • 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 8 '20 at 4: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 8 '20 at 8:22
  • That's a good point but I appreciate you updated your answer to be more precise :). – Juraj Martinka Jul 9 '20 at 4:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.