Sign inSign up

servivum/docker-host-cleanup

By servivum

•Updated 12 months ago

🧹 Cleanup Docker hosts scheduled

Image
0

6.3K

servivum/docker-host-cleanup repository overview

⁠🧹 Docker Host Cleanup

Tool prunes images, containers, networks and volumes scheduled and keeps your Docker hosts clean. See Docker Hub⁠ for more details about it.

⁠Supported Tags

Note: The images on Docker Hub⁠ are automatically updated when a new version of Docker is released.

⁠Technologies

  • Docker CLI
  • Cron

⁠Dependencies

  • Docker

⁠Usage

Note: Don't use tag latest in production. Choose tag corresponding to used Docker version you will get with docker version.

⁠Environment Variables

Control the cleanup behaviour with environment variables.

NameDefaultExampleDescription
CRON_INTERVAL–0 3 * * *Set cron schedule
PRUNE_BUILD_CACHESfalsetrueRemove all unused build caches
PRUNE_BUILD_CACHES_FILTER-until=24hRemove filtered and unused build caches.
PRUNE_CONTAINERSfalsetrueRemove all stopped containers
PRUNE_CONTAINERS_FILTER-until=24hRemove filtered and stopped containers. See Docker docs⁠ for more examples.
PRUNE_IMAGESfalsetrueRemove all unused images
PRUNE_IMAGES_FILTER-until=24hRemove filtered and unused images. See Docker docs⁠ for more examples.
PRUNE_NETWORKSfalsetrueRemove all unused networks. Networks will be removed after container cleanup.
PRUNE_NETWORKS_FILTER-until=24hRemove filtered and unused networks. Networks will be removed after container cleanup. See Docker docs⁠ for more examples.
PRUNE_VOLUMESfalsetrue⚠️ Remove all local volumes which are not referenced by any containers. Networks will be removed after container cleanup.
⁠Option 1: Run as a "Low-level" Container
docker container run \
    --volume /var/run/docker.sock:/var/run/docker.sock \
    --env CRON_INTERVAL="0 3 * * *" \
    --env PRUNE_IMAGES=true \
    servivum/docker-host-cleanup:latest
⁠Option 2: Run as a Service
docker service create \
    --name docker-host-cleanup \
    --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock \
    --env CRON_INTERVAL="0 3 * * *" \
    --env PRUNE_IMAGES=true \
    servivum/docker-host-cleanup:latest
⁠Option 3: Deploy as a Stack

Adapt docker-compose.production.yml to your needs and deploy it with:

docker stack deploy -c docker-compose.production.yml docker-host-cleanup

⁠License

GNU General Public License v3.0

Tag summary

Content type

Image

Digest

sha256:b0964edba…

Size

72 MB

Last updated

12 months ago

docker pull servivum/docker-host-cleanup