If you have encountered unexpected issues while working with Docker… you are in the right place!
Whether you’re a seasoned Docker user or just getting started, you may have encountered some unexpected “hiccups” along the way. In this article, we’ll analyse various Docker hiccups that I have experienced while developing and administrating servers, and try to provide practical solutions to fix them.
Buckle up and get ready to tackle those Docker challenges head-on!
Hiccups Covered
Here is a list of small problems that we will try to fix:
- Huge Container Logs
I plan to update this article from time to time with more small Docker problems that I find interesting.
Huge Container Logs
As a naive and noob Docker user, I was under the impression that each container’s logs were automatically trimmed to minimise disk space usage. But… this is not the case, as Docker by default keeps all the logs… and I had to find it the hard way one day that some services were throwing error 500 and on further inspection, I found out that a server hosting 2 GitLab containers run out of disk space (each instance generated 39GB of logs).
To address the issue, I found out that I could configure each one of my containers to limit the log file in size and number. For projects deployed as a docker-compose.yml
, one can configure the logging behavior of each service to apply these limits. Here is an example:
services:
example:
image: hello-world:latest
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"