• 28/06 cập nhật đăng ký đăng nhập qua Google & Facebook

Dify how to clean up space in Docker Dify

TenHoshi

Administrator
Staff member
Trusted Uploader
I am currently using Dify to manage my projects, and I am looking for a way to delete old or unnecessary data, such as temporary files, logs, or cache. However, I am not sure where these files are stored or the recommended process to clean them up without affecting the system's stability. I would like to know if Dify provides any built-in scripts or commands for this purpose.

image.png


How to clean up space in Docker:​


Remove unused containers:

docker container prune

This command will remove all stopped containers.

Remove unused images:

docker image prune -a

Remove all images that are not used by any container.

Remove unused volumes:

docker volume prune

Remove unnecessary system data:

docker system prune -a --volumes

This command will remove all unnecessary data, including stopped containers, images, volumes, and unused networks.

It seems wrong to delete user uploaded data over 30 days, instead because there are so many deprecated containers each time it is updated, 50GB of memory is full.
 

TenHoshi

Administrator
Staff member
Trusted Uploader

🇻🇳 Giảm dữ liệu Dify (Docker)

🧹 Dọn log tidb-slow trong Docker:​

find /var/lib/docker/overlay2/ -type f -name 'tidb-slow-*.log' -exec truncate -s 0 {} \;

Lệnh này sẽ “xén” toàn bộ các file log tidb-slow về 0 byte để giải phóng dung lượng mà không cần vào từng thư mục.

🐳 Log container bị phình to 24GB?​

File *-json.log trong /var/lib/docker/containers/ là log của container — nếu không giới hạn sẽ rất dễ bị đầy đĩa.

✅ Cách xử lý:
  1. Xoá log thủ công ngay lập tức:
truncate -s 0 /var/lib/docker/containers/<id>/<id>-json.log
  1. (Khuyến nghị) Giới hạn log trong Docker: Tạo/chỉnh file /etc/docker/daemon.json:
Code:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "50m",
"max-file": "3"
}
}

→ Giới hạn log còn 150MB/container.
Sau đó restart Docker:

systemctl restart docker


🇺🇸 Reduce Dify Docker Data – Quick Guide

🧹 Clean up tidb-slow logs in overlay2:​

find /var/lib/docker/overlay2/ -type f -name 'tidb-slow-*.log' -exec truncate -s 0 {} \;

This trims all tidb-slow log files to 0 bytes without deleting them, freeing up space.



🐳 JSON log bloated to 24GB?​


The *-json.log file under /var/lib/docker/containers/ is the container log file. It can grow huge if not limited.

✅ How to fix:
  1. Manually clear it:
truncate -s 0 /var/lib/docker/containers/<id>/<id>-json.log
  1. (Recommended) Limit Docker logs: Edit/create /etc/docker/daemon.json:
Code:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "50m",
"max-file": "3"
}
}

→ This keeps logs at ~150MB per container.
Then restart Docker:

systemctl restart docker
 

Guest Post 2022

Top