Skip to content

scalaone/cleanup-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cleanup your docker daemon periodically

Reason

I am running a gitlab worker for building my arm docker images. Usally it takes a few weeks until the worker is out of disk space.

To prevent this problem I created this small docker utility.

Cleanup

The following commands will be triggered on startup of the container.

docker container prune -f
docker volume prune -f
docker image prune -f

This will delete all unused containers, unbound volumes and unused images.

After the cleanup-commands are processed the container will delay the cleanup for the next 24 hours.

Advise about persistent data

Please be aware that volumes may contain data that should be persisted! Use this image only if you don't store any persistent data on docker volumes!

Usage

For amd64 architecture:

docker container run \
    -d \
    --restart unless-stopped \
    -v /var/run/docker.sock:/var/run/docker.sock \
    jaedle/cleanup-docker:latest

For arm32v7 architecture:

docker container run \
    -d \
    --restart unless-stopped \
    -v /var/run/docker.sock:/var/run/docker.sock \
    jaedle/cleanup-docker:arm32v7

Parameters

The interval of the cleanup (default 24 hours) can be configured through the environment variable CLEANUP_RATE specified in seconds.

This will cleanup each hour:

docker container run \
    -d \
    --restart unless-stopped \
    -e CLEANUP_RATE=3600 \
    -v /var/run/docker.sock:/var/run/docker.sock \
    jaedle/cleanup-docker:latest

About

Cleanup your docker daemon periodically

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 70.6%
  • Shell 29.4%