Using Alpine Linux base image and .dockerignore file to make Docker image even smaller.

This commit is contained in:
Ted M. Young committed 2015-07-07 11:53:12 -07:00
1 parent 68ed0a7dc5
commit 4e1261a0be
3 files changed
+27 -18

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
.git/
debian/
+9 -10
View File
@@ -1,17 +1,16 @@
FROM debian:jessie
FROM gliderlabs/alpine:3.2
ENV DOCKER_VERSION 1.6.2
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y python-minimal \
&& apt-get clean \
&& rm -rf /var/apt/lists/*
# We get curl so that we can avoid a separate ADD to fetch the Docker binary, and then we'll remove it
RUN apk --update add bash curl python \
&& curl -s https://get.docker.io/builds/Linux/x86_64/docker-${DOCKER_VERSION} > /bin/docker \
&& chmod +x /bin/docker \
&& apk del curl \
&& rm -rf /var/cache/apk/*
ADD https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION} /usr/local/bin/docker
RUN chmod +x /usr/local/bin/docker
ADD docker-gc /docker-gc
COPY ./docker-gc /docker-gc
VOLUME /var/lib/docker-gc
CMD ["/docker-gc"]
CMD ["/docker-gc"]
+15 -8
View File
@@ -1,19 +1,20 @@
docker-gc
=========
A simple docker container and image garbage collection script.
A simple Docker container and image garbage collection script.
* Containers that exited more than an hour ago are removed.
* Images that don't belong to any remaining container after that are removed.
Although docker normally prevents removal of images that are in use by
containers, we take extra care to not remove any image tags (e.g. ubuntu:14.04,
containers, we take extra care to not remove any image tags (e.g., ubuntu:14.04,
busybox, etc) that are in use by containers. A naive `docker rmi $(docker images
-q)` will leave images stripped of all tags, forcing docker to re-pull the
repositories when starting new containers even though the images themselves are
still on disk.
This script is intended to be run as a cron job.
This script is intended to be run as a cron job. You can also run it as a Docker
container (see below).
Building
--------
@@ -35,8 +36,8 @@ Installing
$ dpkg -i ../docker-gc_0.0.3_all.deb
```
This installs the `docker-gc` script into `/usr/sbin` and drops a `docker-gc` cron
file into `/etc/cron.hourly/`.
This installs the `docker-gc` script into `/usr/sbin` and drops a `docker-gc`
cron file into `/etc/cron.hourly/`.
Usage
@@ -69,14 +70,20 @@ spotify/cassandra:latest
Running as a Docker Image
-------------------------
A Dockerfile is provided as an alternative to a local installation. By default the container will start up, run a single garbage collection, and shut down.
A Dockerfile is provided as an alternative to a local installation. By default
the container will start up, run a single garbage collection, and shut down.
### Build the Docker Image
```sh
docker build -t spotify/docker-gc .
```
The docker-gc container requires access to the docker socket in order to function.
### Running as a Docker Container
The docker-gc container requires access to the docker socket in order to
function, so you need to map it when running, e.g.:
```sh
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock spotify/docker-gc
```
```