Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a Docker Container and an Ansible Playbook?

It seems to me that both tools are used to easily install and automatically configure applications.

However, I've limitedly used Docker and haven't used Ansible at all. So I'm a little confused.

Whenever I search for a comparison between these two technologies, I find details about how to use these technologies in combination.

like image 606
Steven Roose Avatar asked May 30 '15 19:05

Steven Roose


People also ask

Is Ansible alternative for Docker?

You can use Ansible to orchestrate the deployment and configuration of your Docker containers on the host, or you can use Ansible to construct your Docker container images based on Ansible playbooks as a more powerful alternative to Dockerfiles.

What is the use of Ansible and Docker?

Docker and Ansible An automation tool by Red Hat, Ansible, aims to simplify tasks like configuration management, application deployment, and intra-service orchestration. With its simple architecture, Ansible provides a robust set of features and built-in modules that facilitate writing automation scripts.

Can Ansible manage Docker containers?

Ansible has modules to manage the Docker server, Docker containers, and Docker Compose. These modules are maintained by the community. A dynamic inventory plugin for Docker exists.


1 Answers

There are many reasons most articles talk about using them together.

Think of Ansible as a way of installing and configuring a machine where you can go back and tweak any individual step of that install and configuration in the future. You can then scale that concept out to many machines as you are able to manage.

A key difference where Ansible has an advantage is that it can not just manage the internals of the machine, but also manage the other systems such as networking, DNS, monitoring etc that surround the machine.

Building out many machines via Ansible takes pretty much as much time to do 50 machines as it does to make 1, as all 50 will be created step by step. If you are running a rolling deploy across multiple environments its this build step by step that takes up time.

Now think of Docker as having built one of those individual machines - installed and configured and ready to be deployed wherever a docker system is available (which is pretty much everywhere these days). The drawback here is you don't get to manage all the other aspects needed around making docker containers actually work, and tweaking them long term isn't as much fun as it sounds if you haven't automated the configuration (hence Ansible helps here).

Scaling from 1 to 50 Docker machines once you have already created the initial image is blindingly fast in comparison to the step by step approach Ansible takes, and this is most obvious during a rolling deploy of many machines in smaller groups.

Each has its drawbacks in either ability or speed. Combine them both however and it can be pretty awesome. As no doubt with most of the articles you have already read, I would recommend looking at using Ansible to create (and update) your base Docker container(s) and then using Ansible to manage the rollout of whatever scale of containers you need to satisfy your applications usage.

like image 147
keba Avatar answered Sep 21 '22 06:09

keba