Docker – Creating An Alpine Image With Ansible Installed
As I am experimenting with Docker images and finding the right combination
which works well for me the majority of the time. I have finally put together
Dockerfile which uses Alpine Linux as the base image and installs
Ansible. Why Ansible in a Docker image? Because for me it allows me to
BASH and use a desired state methodology. Now this may not be for
everyone but it works really well for me. Especially when I am using this base
image to do additional complex configuration either during the image creation
or during the spin-up of a container which may require custom provisioning. So,
with this all being said you will find the very simple
Dockerfile below which
will install Ansible for us.
FROM alpine:3.4 MAINTAINER Larry Smith Jr. <firstname.lastname@example.org> RUN apk update && \ apk add --no-cache ansible && \ rm -rf /tmp/* && \ rm -rf /var/cache/apk/*
To build your image simply create the
Dockerfile above and then build the
docker build -t alpine-ansible .
So why Alpine Linux? Because it is small… How small? Let’s compare a few
ubuntu 14.04 b1719e1db756 34 hours ago 188 MB
ubuntu 16.04 45bc58500fa3 34 hours ago 126.9 MB
debian jessie a24c3183e910 33 hours ago 123 MB
alpine 3.4 7d23b3ca3463 28 hours ago 4.799 MB
mrlesmithjr/ubuntu-ansible latest 69c2195ca7d7 31 hours ago 242.2 MB
mrlesmithjr/alpine-ansible latest 5291ba47263e 26 hours ago 65.01 MB
So there you have it…
FROM mrlesmithjr/alpine-ansible ...
Or, even build your own image now.