Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Automate Installing Docker and Docker Compose with Ansible

blog/cards/automate-installing-docker-and-docker-compose-with-ansible.jpg

I'm sure at some point you'll want to install Docker and Docker Compose on your production server, and Ansible makes it easy.

Quick Jump: Where Did This Article Go?

I’m a huge fan of using Docker and Ansible together, so it’s no surprise that I let Ansible handle installing Docker and Docker Compose in production.

Where Did This Article Go?

For a while now I’ve duplicated most of the role’s README file in this article, but trying to keep track of the changes in 2 spots got a little tedious.

Here’s the TL;DR on what the Ansible Docker role does:
  • Install Docker (editions, channels and version pinning are all supported)
  • Install Docker Compose using PIP (version pinning is supported)
  • Install the docker PIP package so Ansible’s docker_* modules work
  • Manage Docker registry login credentials
  • Configure 1 or more users to run Docker without needing root access
  • Configure the Docker daemon’s options and environment variables
  • Configure a cron job to run Docker clean up commands

You can check out the full details on GitHub.

And if you’re wondering, yes, I am using it in production.

Let me know how it goes in the comments.

Free Intro to Docker Email Course

Over 5 days you'll get 1 email per day that includes video and text from the premium Dive Into Docker course. By the end of the 5 days you'll have hands on experience using Docker to serve a website.



Comments