When comparing Docker vs Ansible, the Slant community recommends Ansible for most people. In the question“What are the best WordPress deployment tools?” Ansible is ranked 1st while Docker is ranked 4th. The most important reason people chose Ansible is:
Ansible does not use agents. Instead, all master-agent communications are handled via SSH commands or through the Paramiko module which provides a Python interface to SSH.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Allows for portable application deployment
Docker creates a single object, containing an application with its dependencies, that can be moved between any docker-enabled machines, guaranteeing the same environment for application execution.
Pro Git-like capabilities
Docker tracks changes in systems. It allows for commits and rollbacks and for quick deployment due to having to deploy only the updated code.
Pro Allows re-using components
Docker essentially allows creating boilerplate systems (a LAMP stack, for example) that can be used as a starting point on multiple projects. And you can find multiple such containers already created by people in their public registry.
Pro Automatic build
Allows automatically assembling a container from its source code.
Pro Provides easy sharing and installation of containers through a public registry
Docker allows easily pushing and pulling containers to and from their public index.docker.io registry. Additionally, dotCloud maintains a list of official repositories of the more popular containers.
Pro Application-centric
Pro Works in virtualized environments
You can set up Docker within an already virtualized environment such as a virtual machine. This allows you to run Docker on Mac and Windows, among other use-cases.
Pro Low overhead
Pro Supports a wide range of isolation tools
Docker can be used with OpenVZ, systemd-nspawn, libvirt-lxc, libvirt-sandbox, qemu/kvm, BSD Jails, Solaris Zones, and chroot.
Pro Tool ecosystem
Pro Agentless
Ansible does not use agents. Instead, all master-agent communications are handled via SSH commands or through the Paramiko module which provides a Python interface to SSH.
Pro Gentle learning curve
Ansible is agentless, making it quick and painless to setup. Ansible has clear and detailed documentation and provides plenty of built-in modules. Its DSL is obtained using YAML and a familiar template system.
Pro Simple tasks can be run from the command line
Some simple tasks such as triggering updates or reboots, or even checking if the service is running can be done without configuration files. These commands can be run from the command line instead.
Pro Support for major cloud providers
Ansible supports managing major cloud devices (AWS, RackSpace, Digital Ocean, OpenStack) through a collection of modules which are available.
Pro Extensible in any language / runtime
Although you may need to preinstall favorite programming environment, Ansible modules are accessed via shell calls and therefore any executable on the remote system built for use with Ansible may be used as an Ansible module.
Pro Web UI
Ansible has a Web UI in the form of AnsibleWorks AWX which unfortunately does not tie directly into the CLI. So configuration elements present in the CLI can not appear in the UI unless a sync pass is run. Although the Web UI is helpful and functional, it's still not as complete feature-wise as the CLI.
Pro Easy to customize
Ansible is very easy to customize. It doesn't force you to use a language with which you are unfamiliar. Instead, all commands are packaged into YAML modules which are called playbooks. So as long as you use a programming language that can output JSON, you are able to customize it.
Pro Rich diff
Modules that support rich diffs can expose nearly every detail of what will change. However not all core modules support diffs, so there may still be some opaque chances made.
Pro Creating reusable components is simple
Making roles modular and reusable is a fast process with Ansible.
Cons
Con Large image size
Con Security concerns
Con Kernel OS fragmentation
Con Slow
Compared to other tools, Ansible requires more time to complete the same actions.
Con Somewhat weak documentation
Ansible is still relatively new, as far as server automation tools go. This is the reason that many users have found it's documentation lacking in some parts. Although this is mitigated by the fact that it's very easy to learn to use.
Con Too easy to move the port in the crappy scripts you've been using for years
If you have an extensive codebase of scripts, your users might find it too easy to just port in the same unsupportable crappy scripts they've been using for years.
Con Doesn't have its own inventory system
Ansible really depends on you to provide it a list of nodes to run on and doesn't actively maintain a central inventory
Con No Python API available, despite the fact that Ansible is written in Python
Despite being written and taking good advantage of the python environment, Ansible offers no python api for programming, and does not make it possible to follow best practices for writing custom Ansible modules.