GithubHelp home page GithubHelp logo

parshyn-dima / docker_gc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pdacity/docker_gc

0.0 0.0 0.0 41 KB

Garbage collector for Docker Swarm / Автоматическая сборка мусора для Docker и Docker Swarm

License: MIT License

Dockerfile 46.47% Shell 53.53%

docker_gc's Introduction

Garbage collector for Docker Swarm

Awesome Docker Docker Cloud Build Status Docker stuff PizzaWare Tea powered

About

Image for automatic removing unused Docker Swarm objects. Also works just as Docker Service.

By default these types of objects are deleted:

  • container
  • volume
  • network

Configuration

Set config parameters in the yml file:

  • AGE - the max time for resource to be unused (format: timestamp or Go duration strings (10m, 1h30m))
  • SLEEP - the time frame between checking for unused objects (format: timestamp or Go duration strings (10m, 1h30m))
  • STICKY_LABEL - do not remove image with this label

Building image with STICKY_LABEL

If you need to protect an image from automatic deletion use LABEL directive, for example: persistent_image=true. To do it just create Dockerfile for you image .

FROM <IMAGENAME>
LABEL persistent_image=true

Before run the stack build the image from Dockerfile mentioned above:

docker-compose.yaml

...
  <SERVICENAME>
    container_name: <CONTAINERNAME>
    build:
      context: .
...
  • <IMAGENAME> - the image which is protected from automatic deletion
  • <SERVICENAME> - service name in the stack
  • <CONTAINERNAME> - container name (optionally)

Also you should set STICKY_LABEL: persisten_image=true in the docker_gc run variables

Run

  • docker-stack.yml - to deploy the service in Docker Swarm
  • docker-compose.yml - to run just a Docker Service

Docker Hub

Prebuild docker image on hub.docker.com - https://hub.docker.com/r/pdacity/docker_gc


Сборщик мусора для Docker Swarm и Docker

Docker Cloud Build Status Docker stuff PizzaWare Tea powered

О проекте

Образ для автоматической очистки неиспользуемых обьектов в Docker Swarm (работает и просто как Docker Service )

По умолчанию удаляются следующие типы обьектов:

  • container
  • volume
  • network

Настройка

Для работы необходимо задать параметры yml файле:

  • AGE - срок в формате timestamp или Go duration strings (10m, 1h30m) после которого неиспользуемые ресурсы будут удалены
  • SLEEP - периодичность проверки в формате timestamp или Go duration strings (10m, 1h30m)
  • STICKY_LABEL - не удалять образа с этой меткой

Сборка образа с STICKY_LABEL

В случае если необходимо защитить какой либо из образов от автоматического удаления необходимо добавить к образу label, например persistent_image=true Для этого создайте Dockerfile для образа <IMAGENAME>

FROM <IMAGENAME>
LABEL persistent_image=true

При запуске стека необходимо собрать образ из приведенного выше Dockerfile

docker-compose.yaml

...
  <SERVICENAME>
    container_name: <CONTAINERNAME>
    build:
      context: .
...

где <IMAGENAME> - название образа который должен быть защищен от автоматического удаления, <SERVICENAME> - название сервиса в стеке, <CONTAINERNAME> имя контейнера (опционально)

И задайте STICKY_LABEL: persistent_image=true в переменных запуска docker_gc

Запуск

  • docker-stack.yml - для деплоя сервиса в Docker swarm
  • docker-compose.yml - для запуска Docker Service

Docker Hub

Готовый собранный образ на hub.docker.com - https://hub.docker.com/r/pdacity/docker_gc


References: English version of the documentation - https://habr.com/en/users/AlexanderTyutin/

docker_gc's People

Contributors

alexandertyutin avatar legioner0 avatar pdacity avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.