The purpose of this article is to explore the reasons why the docker log file size will increase and could potentially fill up your disk space in a short amount of time. If you have a host machine running Docker with log monitoring and/or log rotation in place, you may still fill up your disk space if you are not careful.
Docker stores a container log in the following directory location:
/var/lib/docker/containers/CONTAINER_ID/CONTAINER_ID-json.log
The log will continue to grow with output from standard out.
Max docker log file size
Docker run
To provide a max file size for this log you may append the following option to your docker run command:
--log-opt max-size=50m
Where 50m is the size of the file, which should be set to the file size of your choice.
Docker compose
Alternatively, if you are using docker compose instead of the docker run
command you can configure the max log file size for your docker container in the docker compose script.
logging:
driver: "json-file"
options:
max-size: 50m
Where driver is the type of driver and max-size is the maximum file size of your docker log file.
Conclusion – Docker file log size
This article has demonstrated a couple of different methods for limiting the max size of log files generated by your docker containers. Let us know in the comments if you have any questions or would like to see more examples of how to reduce the size of your docker log files.
Leave a Reply