this post was submitted on 12 Jun 2023
8 points (100.0% liked)

Lemmy Administration

64 readers
2 users here now

Anything about running your own Lemmy instance. Including how to install it, maintain and customise it.

Be sure to check out the docs: https://join-lemmy.org/docs/en/administration/administration.html

If you have any problems, describe them here and we will try to help you fixing them.

founded 4 years ago
MODERATORS
8
Docker container logging (self.lemmy_admin)
submitted 2 years ago* (last edited 2 years ago) by ruud to c/[email protected]
 

I see many questions, thought I'd make a post :-)

So when running Lemmy in Docker, you'll see your / filesystem gets filled up quickly. That's mainly in /var/lib/docker/containers. It's the logging of the containers.

Docker will default save all logging. Also when you docker-compose stop and restart, the logging stays. Only when re-creating the containers (docker-compose down;docker-compose up -d) it will clear the logs.

Why is my container logging this much?

In the docker-compose.yml you'll see an environment variable RUST_LOG= which is set to info. This logs all informational messages.

You can set this to warn instead to only get warning and error messages. (Requires container recreate)

How to manually cleanup the log without restart

You can find the log of a container with

docker inspect --format='{{.LogPath}}' <containername>

You can then wipe it by typing '> ' (so greater than followed by space) followed by the file path+name.

(Removing it while the container runs wil not really remove it, you'll just no longer see it but it still exists and grows as long as the container runs)

How to prevent logs from growing too large

You can set a max for log file size in your docker-compose.yml using these lines for every container:

    logging:
      driver: "json-file"
      options:
        max-size: "100m"
top 5 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 2 years ago

thanks for the tip, pictrs in particular was taking up a lot of space with its log

[–] lodion 1 points 2 years ago (1 children)

You missed the container name:
docker inspect CONTAINERNAME --format='{{.LogPath}}'

Great post, thanks for the info.

[–] ruud 1 points 2 years ago

I have the containername as last , but it wrapped to a new line. I'll change that to make more clear

[–] [email protected] 1 points 2 years ago

Helpful post, thank you!

[–] [email protected] 1 points 2 years ago

Huge thank you! I had a feeling something like this was going on but had no idea how to troubleshoot/fix.

My pictrs and lemmy containers were the biggest between 3-8 GB (significant for a smaller instance) after a couple weeks.

For anyone who finds this, in addition to what OP provided here, another command I found helpful (since I am a docker noob 🙂) to find the name of the currently running containers:

docker ps --format '{{.Name}}'