docker-gc

command module
v0.0.0-...-6de8aa2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

Docker Garbage Collector

Run Status

Logo

Introduction

Docker is cool, but the way it manage container images has a side effect : after you destroyed a container, the image it has been built on remains. In many cases, this results in a growing /var/lib/docker directory as you get new images (or image updates) running on your docker host.

Docker-gc is a garbage collector process, which will remove obsolete docker images from your host, without impacting the running containers.

Design

Docker-gc is a resident process, listening on docker daemon events for container destroyed events. This event is used to determine last used of underlying image. When an image isn't used by any container, and last use is older than gc limit, the image is removed.

Usage

run docker-gc to automatically purge unused images after 2 days. Default max age is 72 hours, so your docker images will survice a week-end. You can override with --maxAge [duration] using Golang duration syntax, for sample --maxAge 60m

For your convenience, docker-gc is also available as a docker image. You can run it as docker run -d -v /var/run/docker.sock:/var/run/docker.sock ndeloof/docker-gc You need to bind mount /var/run/docker.sock from docker host so the docker-gc process can attach to the daemon to listen for event and inspect/remove images.

You can also use docker-gc.service to deploy Docker-gc everywhere using Fleet on a CoreOS cluster. Just run fleetctl start docker-gc.service.

Note

once https://github.com/moby/moby/issues/4237 has been addressed, docker-gc could be significantly simplified.

Documentation

Overview

*

  • Copyright 2015 Nicolas De Loof *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • https://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL