How to cleanup sentry in docker

i want to do a regular cleanup of sentry and somehow can’t find a clean way to do this.

we run docker on-premise with the default docker-compose.yml. i know, i can run cleanup like this: docker-compose run --rm worker cleanup --days 120 and trigger that by cron.

the problem is: every time i do this, docker starts the containers for postgres/redis/… too. i dont think its a good idea to run those twice with the same volumes mounted.

i could stop sentry, run the cleanup and start sentry up again, but somehow that feels very wrong and would result in downtime every time i run cleanup.

is there a nicer/cleaner solution i cant see?


Hi bmaeser,

I was looking into this problem today. Came across a few people who had asked the question on the forum but had no reply.

I managed to figure out a way that works for us.

using the command:

/usr/bin/docker-compose --file /path/to/docker-compose.yml exec worker sentry cleanup --days 30

Specifically, using “exec” not “run”. This runs the command in an existing container.

I then set up the cron job to run that command daily.


thx @cemenson, i had this tested over a couple of weeks now, works great!