Ansible "couldn't resolve module/action": install the collection, or fix the name
Fix Ansible "couldn't resolve module/action": install the missing collection, use the full module name, and check the Python environment.
by OhSudo ·
Checked on real software: Ansible · November 2026How we check
[ERROR]: couldn't resolve module/action 'community.docker.docker_container'. This often indicates a misspelling, missing collection, or incorrect module path.Origin: /home/deploy/site/playbook.yml:4:7Older versions of ansible-core start it with ERROR!, and have no Origin line, which here points to the task’s line and column. The message lists the three causes, and the first one is by far the most common now: the module lives in a collection that isn’t installed.
Since Ansible 2.10, most modules moved out of Ansible itself, into collections. The name before the last dot, here community.docker, is the collection. If you installed ansible-core alone, only the built-in ansible.builtin modules are there.
TL;DR
ansible-galaxy collection list community.dockeransible-galaxy collection install community.dockerThen run the playbook again. For a team, list collections in requirements.yml: section 3.
1. Is the collection there?
ansible-galaxy collection listansible-galaxy collection list community.dockerIf it’s not listed, install it:
ansible-galaxy collection install community.dockerCheck what you have installed, too:
ansible --versionpip show ansible ansible-core 2>/dev/null | grep -E '^(Name|Version)'The ansible package includes many popular collections, community.docker among them. The ansible-core package doesn’t. Installing just ansible-core is fine, as long as you add the collections you use.
2. Is the name right?
Since collections, modules have full names, called FQCNs:
| Old short name | Full name |
|---|---|
docker_container |
community.docker.docker_container |
mysql_user |
community.mysql.mysql_user |
postgresql_db |
community.postgresql.postgresql_db |
firewalld |
ansible.posix.firewalld |
win_service |
ansible.windows.win_service |
copy, template, apt |
ansible.builtin.copy, and so on |
Look up a module’s real name, which also confirms it’s installed:
ansible-doc -l | grep docker_containeransible-doc community.docker.docker_containerA typo in any part of the name gives the same error. So does a module that was removed: very old playbooks may use names that no longer exist in any collection. ansible-doc and the collection’s documentation give the replacement.
A YAML mistake can also look like this. If a task’s keys are indented wrongly, Ansible may read an option, like name:, as the module. If the “module” in the message is a word like name, check the task’s indentation, and see mapping values are not allowed.
3. Make it repeatable: requirements.yml
So that every machine and pipeline has the same collections, list them in the project:
collections: - name: community.docker version: ">=4.0.0" - name: ansible.posixansible-galaxy collection install -r collections/requirements.ymlRun that in CI before the playbook.
4. Installed, and still not found
Then Ansible is looking somewhere else:
- Another Python environment.
ansible-playbookfrom one virtual environment, collections installed by another. Comparewhich ansible-playbookwithwhich ansible-galaxy, and look at theansible collection locationline inansible --version. - A collections path in
ansible.cfg, withcollections_path, orANSIBLE_COLLECTIONS_PATHset, that doesn’t include where you installed.ansible-config dump --only-changedshows settings that differ from the default. sudo: collections installed for your user are in~/.ansible/collections, which root doesn’t see. Don’t runansible-galaxywithsudofor your own playbooks.
Warning
Pin collection versions in requirements.yml for anything that runs in production. A new major version of a collection can change modules’ options, and a playbook that worked yesterday then fails, or does something different, after a fresh install.
Shell, we have a problem!
Similar, but different: UNREACHABLE! Failed to connect to the host means Ansible can’t reach the machine at all. Missing sudo password means it connected and can’t become root. couldn't resolve module/action 'docker_container', with a short name, is this same problem: install the collection, and use the full name. YAML errors are in mapping values are not allowed. For everyday commands, see the Ansible cheat sheet.
Found this useful? Share it.
Found a mistake? Let us know at contact@ohsudo.com.