Note
This plugin is part of the community.docker collection (version 1.10.0).
You might already have this collection installed if you are using the ansible
package. It is not included in ansible-core
. To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.docker
.
To use it in a playbook, specify: community.docker.current_container_facts
.
New in version 1.1.0: of community.docker
- name: Get facts on current container community.docker.current_container_facts: - name: Print information on current container when running in a container ansible.builtin.debug: msg: "Container ID is {{ ansible_module_container_id }}" when: ansible_module_running_in_container
Facts returned by this module are added/updated in the hostvars
host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.
Fact | Returned | Description |
---|---|---|
ansible_module_container_id string / elements=string | always | The detected container ID. Contains an empty string if no container was detected. |
ansible_module_container_type string / elements=string | always | The detected container environment. Contains an empty string if no container was detected. Otherwise, will be one of docker or azure_pipelines . |
ansible_module_running_in_container boolean / elements=string | always | Whether the module was able to detect that it runs in a container or not. |
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/docker/current_container_facts_module.html