1

We are running Century Link's Watchtower container. This allows us to have a watch a docker registry and download new images when they are created. When watchtower finds a new image it runs docker rmi which deletes the old container. With that the old logs go with it.

Is there a way without using a logging service to retain the logs when docker does it's clean up?

Jon Harding
  • 111
  • 2
  • 1
    Why are you averse to using a centralized logging service? It's something you should be doing anyway. – EEAA Mar 17 '16 at 19:43
  • Has to do with our clients requiring them to open up outgoing ports. Ideally we would have an external system, trust me – Jon Harding Mar 17 '16 at 20:02

1 Answers1

2

You've written "docker rmi" but I guess you meant "docker rm ..." as rm is for removing containers and rmi is for images(unless you are using --cleanup option to remove images).

You just have to give the -v parameter to your docker run command as in:

$ docker run -d -P -v /log_directory docker_image ...

and also you need to direct your logs to that docker volume(log_directory). By this way your log_directory will be permanent even if container is removed

https://docs.docker.com/engine/userguide/containers/dockervolumes/

VolkanT
  • 121
  • 4