Created
March 4, 2018 06:04
-
-
Save bngsudheer/351214ea2ffdbde571b4a7c4bd9fdc33 to your computer and use it in GitHub Desktop.
How To Run A Docker Container Using Ansible On localhost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
tasks: | |
- name: Create a data container | |
docker_container: | |
name: my-test-container | |
image: python:2.7 | |
command: /bin/sleep 600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
all: | |
hosts: | |
127.0.0.1: | |
ansible_connection: local | |
ansible_python_interpreter: /home/sudheer/workspace/pvenvs/ansibleenv/bin/python | |
# /home/sudheer/workspace/pvenvs/ansibleenv/bin/python is the python virtualenv where docker-py is installed | |
# docker-py==1.10.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ansible-playbook -i inventory.yml d-play.yml | |
PLAY [all] ******************************************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************** | |
ok: [127.0.0.1] | |
TASK [Create a data container] ************************************************************************************************************************************************************************************ | |
ok: [127.0.0.1] | |
PLAY RECAP ******************************************************************************************************************************************************************************************************** | |
127.0.0.1 : ok=2 changed=0 unreachable=0 failed=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment