To create a Docker image, you usually use Docker CLI with the
docker build command. One of the advantages is that this command creates one layer per line of the Dockerfile.
However, when you create several Docker images with common code, it may be appropriate to use the Ansible role concept.
Packer helps us to integrate Ansible into the process of building a Docker image. It is then possible to share common parts of Docker images via Ansible roles. But the disadvantage is that you no longer benefit from Docker’s layer-based…