Ansible Docker Base

Ansible base Images for easy Ansible-Playbook-based Docker builds
Alternatives To Ansible Docker Base
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Devops Exercises41,762
5 days ago14otherPython
Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions
a day ago11April 25, 202148apache-2.0Jinja
Ansible For Devops6,699
a month ago90mitPython
Ansible for DevOps examples.
a month ago17gpl-3.0Go
Modern self-hosting framework, fully automated from empty disk to operating services with a single command.
Devops Guide6,318
a month ago5mitHTML
DevOps Guide - Development to Production all configurations with basic notes to debug efficiently.
17 days ago33apache-2.0Go
KubeOperator 是一个开源的轻量级 Kubernetes 发行版,专注于帮助企业规划、部署和运营生产级别的 K8s 集群。
5 days ago38apache-2.0Jinja
Your favorite operating systems in one place. A network-based bootable operating system installer based on iPXE.
25 days ago67gpl-3.0Python
Ansible Nas2,378
3 days ago119mitJinja
Build a full-featured home server or NAS replacement with an Ubuntu box and this playbook.
Ansible Container2,2681014 years ago8September 12, 2017200lgpl-3.0Python
DEPRECATED -- Ansible Container was a tool to build Docker images and orchestrate containers using only Ansible playbooks.
Alternatives To Ansible Docker Base
Select To Compare

Alternative Project Comparisons


Ansible no longer maintains images in Dockerhub directly. There are several Ansible images on Dockerhub that are maintained by members of the Ansible community, which you can find with the following search


These are base docker images that include Ansible.

Ansible, Inc maintains these images so that people can easily build docker images from ansible playbooks.

While Ansible modules can help you deploy container images (and also prepare host dependencies to be able to run containers), this document is about how to use ansible to efficiently describe and build them as well.

Obtaining these Images from DockerHub

Ansible, Inc content on DockerHub lives at

There are base images available currently for CentOS 7 and Ubuntu 14.04 LTS, using both the latest stable version of Ansible as well as development branch snapshots.

Building Your Own Container Based on an Ansible Image

By specifying a Dockerfile, it is easy to describe a container image primarily defined by an ansible-playbook, using a very minimal Dockerfile.

Take a look at this Dockerfile for a sample of what one looks like.

To build this image, simply cd into the directory that contains the Dockerfile and run:

docker build -t webserver_simple .

This will produce an image tagged "webserver_simple" based on the Ansible playbook run. Here's the playbook that defines the configuration.

Your own content will probably be kept in it's own git repos. You may wish to connect your repositories containing Ansible+Docker playbooks to DockerHub, to trigger automatic rebuilds of your container images when your underlying ansible playbooks, or the applications they might embed, change.

Selecting Versions of Ansible

The DockerFile shown above selected the latest CentOS tag of Ansible's Docker images. The first line of the DockerFile can be changed to select another base operating system or Ansible version should you wish to use a different OS or different Ansible version.

The following options are available:

FROM ansible/centos7-ansible:stable
FROM ansible/centos7-ansible:devel
FROM ansible/ubuntu14.04-ansible:stable
FROM ansible/ubuntu14.04-ansible:devel

Ansible images on DockerHub will be updated periodically.

Jumping Docker Content with Ansible Galaxy

While Ansible provides 240+ modules for managing various aspects of IT components and is a great starting point for describing your applications, Ansible Galaxy provides complete automation for deploying a very large number of popular apps and takes this to the next level.

To use existing ansible-role content within Docker, simply switch into a playbook directory and download the roles. For example, to configure the ELK stack:

mkdir roles/
cd roles/
ansible-galaxy install bakhti.elk

And then leverage the role content in the playbook:

- hosts: localhost
    - bakhti.elk

So, a 3 line playbook then brings up an entire ELK stack in a container image :)

Deploying Your Ansible-Built Docker Containers with Ansible

Once available on a registry, images can be deployed using the Ansible Docker Module. This can be a lightweight way to specify what containers should run on which hosts.

Here's a minimal example of running a Tomcat container on all of your hosts:

- hosts: web
  sudo: yes
    - name: run tomcat servers
      docker: image=my-tomcat command="service tomcat6 start" ports=8080

Replace the "image" parameter with the name of the image above in your registry.

For more information, consult the Ansible Docker module documentation

As your needs grow more detailed and you wish to specify different containers for different hosts, you might have a list called "run_containers" defined per Ansible host group, saying which containers to run on each host. This can allow ansible to be used as a lightweight cloud, all without any additional moving parts.

Rebuilding Automatically when the Ansible Image Updates

If you are using a Docker Hub automated build to build your images you can set your image to rebuild whenever the base ansible image (hosted by Ansible, Inc) is updated:

  1. Go to the docker hub page for your repository.
  2. In the sidebar labeled "Settings", find the entry marked "Repository Links"
  3. On the "Repository Links" page, enter the Ansible repository you are layering your image on top of. For instance, if you are using the ubuntu14.04-ansible repository, enter ansible/ubuntu14.04-ansible into the "Repository Name" box and click "Add".
  4. Docker hub will now automatically rebuild your image whenever that ansible repository has a new build.


If you'd like to talk about Ansible+Docker, stop by the ansible-project mailing list or #ansible on for IRC.

Popular Docker Projects
Popular Ansible Projects
Popular Virtualization Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.