community / community.docker / 3.5.0 / module / current_container_facts Return facts about whether the module runs in a container | "added in version" 1.1.0 of community.docker" Authors: Felix Fontein (@felixfontein)community.docker.current_container_facts (3.5.0) — module
Install with ansible-galaxy collection install community.docker:==3.5.0
collections: - name: community.docker version: 3.5.0
Return facts about whether the module runs in a Docker or podman container.
This module attempts a best-effort detection. There might be special cases where it does not work; if you encounter one, L(please file an issue, https://github.com/ansible-collections/community.docker/issues/new?assignees=&labels=&template=bug_report.md).
- 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
ansible_facts: contains: ansible_module_container_id: description: - The detected container ID. - Contains an empty string if no container was detected. returned: always type: str ansible_module_container_type: choices: - '' - docker - azure_pipelines - github_actions - podman description: - The detected container environment. - Contains an empty string if no container was detected, or a non-empty string identifying the container environment. - V(docker) indicates that the module ran inside a regular Docker container. - V(azure_pipelines) indicates that the module ran on Azure Pipelines. This seems to no longer be reported. - V(github_actions) indicates that the module ran inside a Docker container on GitHub Actions. It is supported since community.docker 2.4.0. - V(podman) indicates that the module ran inside a regular Podman container. It is supported since community.docker 3.3.0. returned: always type: str ansible_module_running_in_container: description: - Whether the module was able to detect that it runs in a container or not. returned: always type: bool description: Ansible facts returned by the module returned: always type: dict