Reputation: 253
I want to collect docker container logs, By default, log files will be deleted when removing container. It cause several logs lost each time i update my service. How to keep log files after removing containers? Or, Is there another way to collect all logs from containers without losing?
Upvotes: 5
Views: 3077
Reputation: 108
There will be two situations:
docker logs CONTAINER_ID > container.log
# Copy the logs out to the host
docker copy CONTAINER_ID:/path/to/your/log_file /host/path/to/store
# Mount a directory for them
docker run -d \
-v /host/path/to/store/logs:/container/path/stored/logs \
your-image
Upvotes: 5