How to modify the location where Docker logs are stored?
To change the Docker log storage location, you can follow these steps:
- Stop Docker service.
- Stop the Docker service using sudo.
- Edit the Docker startup configuration file.
- open the file daemon.json located in /etc/docker/ using the text editor nano
- Add the following content to the file to configure a new log storage location:
- {
“log-driver”: “json-file”,
“log-configuration”: {
“maximum-size”: “10m”,
“maximum-files”: “3”,
“file-path”: “/var/log/docker/custom.log”
}
} - This will store Docker logs in the /var/log/docker/custom.log file, with each file being limited to a maximum size of 10MB and retaining only up to 3 files.
- Save and close the file.
- Start Docker service.
- Start the Docker service using sudo.
Now, Docker logs will be stored in the newly specified location.