Run the following command to run a basic test of the Ansible docker container:
$ docker run --rm vwnio/ansible ansible all -c local -i 127.0.0.1, -m ping
Assuming ansible files in the current working directory:
$ docker run --rm --name ansible -v ${PWD}:${PWD} -v ~/.ssh:/root/.ssh:ro --workdir ${PWD} vwnio/ansible ansible
To make it easier to use ansible you can create bash aliases, like so:
alias ansible='docker run -it --rm -u "$(id -u):$(id -u)" -v /etc/passwd:/etc/passwd:ro -v "${PWD}":/ansible:ro -v "${HOME}":"${HOME}" --workdir=/ansible vwnio/ansible:latest ansible'
alias ansible-inventory='docker run -it --rm -u "$(id -u):$(id -u)" -v /etc/passwd:/etc/passwd:ro -v "${PWD}":/ansible:ro -v "${HOME}":"${HOME}" --workdir=/ansible vwnio/ansible:latest ansible-inventory'
alias ansible-playbook='docker run -it --rm -u "$(id -u):$(id -u)" -v /etc/passwd:/etc/passwd:ro -v "${PWD}":/ansible:ro -v "${HOME}":"${HOME}" --workdir=/ansible vwnio/ansible:latest ansible-playbook'
alias ansible-galaxy='docker run -it --rm -u "$(id -u):$(id -u)" -v /etc/passwd:/etc/passwd:ro -v "${PWD}":/ansible:ro -v "${HOME}":"${HOME}" --workdir=/ansible vwnio/ansible:latest ansible-galaxy'
alias ansible-vault='docker run -it --rm -u "$(id -u):$(id -u)" -v /etc/passwd:/etc/passwd:ro -v "${PWD}":/ansible:ro -v "${HOME}":"${HOME}" --workdir=/ansible vwnio/ansible:latest ansible-vault'