Search code examples
dockeransible

Is it desirable to use Ansible for creating a docker image


I know we can create Docker images using Ansible. I'm learning and doing PoC work.

I'm trying to find what are the pros/cons of creating a Docker image using Ansible.

Would like to hear if you have played and found any issues/solutions with creating Docker images (NOT deploying Docker images) using Ansible?

Also, are there any good reasons not to create docker images using Ansible?


Solution

  • It can be a good choice.

    • If an agentless system is good enough for your needs, keeping your Docker images lightweight (by not having any agent in them) is a reasonable thing to desire.
    • If your ops team uses Ansible, using the same playbooks in configuring your Docker images (used for dev/test) as for production is desirable.
    • If your production environment uses Docker in the manner in which it's intended to be used, then you have reduced need for complex logic around maintenance and upkeep of existing systems, which makes Ansible a better option.

    That said, I also have a laundry list of complaints about Ansible -- particularly, in places where its DSL is poorly designed in ways that make automating generation of playbooks error-prone, and places where functionality present in some of its competitors (albeit not particularly relevant to Docker image generation) was designed in only as an afterthought.

    No tool is perfect; the decision in terms of what meets your needs and fails only in ways you find acceptable needs to be made in the context of your own use cases.