This installs Ansible in a basic Debian Bullseye Python 3.10 image.
- Grab the image from DockerHub
docker pull isometimescode/ansible-playbook:latest
- Grab a specific version of Ansible from DockerHub
docker pull isometimescode/ansible-playbook:2.10.3
- Run a container and check the installed version of ansible
docker run -t --rm -v $(pwd)/my-local-playbook:/playbook isometimescode/ansible-playbook --version
- Run a container and mount a volume with your playbook contents to execute a play
docker run -it --rm -v $(pwd)/my-local-playbook:/playbook isometimescode/ansible-playbook /playbook/main.yml
Build Arguments | Default Value |
---|---|
ANSIBLE_VERSION |
6.0.0 |
PLAYBOOK_DIR |
/playbook |
The environment variable ANSIBLE_CONFIG
is set with the default value of $PLAYBOOK_DIR/ansible.cfg
e.g. /playbook/ansible.cfg
.
For example, you can build a new image with a specific version of ansible:
docker build . -t ansible-playbook:2.9.13 --build-arg ANSIBLE_VERSION=2.9.13