To setup log rotation on docker compose simply add this
logging:
driver: "json-file"
options:
max-size: "1k"
max-file: "3"
so example docker-compose.yml
file
database:
image: postgres:14.5-alpine
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER: user
volumes:
- ./data:/var/lib/postgresql/data:rw
logging:
driver: "json-file"
options:
max-size: "1k"
max-file: "3"