`ERROR! couldn't resolve module/action 'community.docker.docker_container'. This often indicates a misspelling, missing collection, or incorrect module path.`
BeginnerTroubleshootingRoles, Collections and Galaxy
Answer
Likely causes → The collection is not installed for the Python and Ansible being used. Typical situations: a minimal ansible-core install, a different virtualenv, or an execution environment that does not include it. A typo in the FQCN gives the same error.
Diagnose →
ansible-galaxy collection list | grep -i docker
ansible-doc community.docker.docker_container | head -5
which ansible-playbook && ansible --version
Fix →
# collections/requirements.yml
collections:
- name: community.docker
version: ">=3.10.0,<5.0.0"
ansible-galaxy collection install -r collections/requirements.yml
Prevent → Keep a version-pinned collections/requirements.yml in the repo, and use it in CI, in AWX projects and in ansible-builder definitions.