There are two simple ways to pass hostname
of the machine running docker daemon to the docker container using Ansible.
- name: Start application container
docker:
name: my_application
image: my_username/my_application
env:
HOST_HOSTNAME: "{{ "{{ ansible_hostname " }} }}"
- name: Start application container
docker:
name: my_application
image: my_username/my_application
hostname: "{{ "{{ ansible_hostname " }} }}"