How to modify the location where Docker logs are stored?

To change the Docker log storage location, you can follow these steps:

  1. Stop Docker service.
  2. Stop the Docker service using sudo.
  3. Edit the Docker startup configuration file.
  4. open the file daemon.json located in /etc/docker/ using the text editor nano
  5. Add the following content to the file to configure a new log storage location:
  6. {
    “log-driver”: “json-file”,
    “log-configuration”: {
    “maximum-size”: “10m”,
    “maximum-files”: “3”,
    “file-path”: “/var/log/docker/custom.log”
    }
    }
  7. 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.
  8. Save and close the file.
  9. Start Docker service.
  10. Start the Docker service using sudo.

Now, Docker logs will be stored in the newly specified location.

bannerAds