# Community.docker.docker\_compose

**URL:** <https://forum.ansible.com/t/community-docker-docker-compose/3519>\
**Category:** Get Help\
**Tags:** playbook, docker, collections\
**Created:** [January 29, 2024, 5:18pm UTC](https://forum.ansible.com/t/community-docker-docker-compose/3519 "2024-01-29T17:18:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RoFrie](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@RoFrie](https://forum.ansible.com/u/RoFrie)\
**Post date:** [January 29, 2024, 5:18pm UTC](https://forum.ansible.com/t/community-docker-docker-compose/3519/1 "2024-01-29T17:18:59Z")

</div>

all this is based on a German computer magazine:  
**c’t 2024, Heft 1 …**

using community.docker.docker\_compose with:

```auto
- name: "{{ docker_compose_params.command }}: docker compose '{{ service_cfg.name }}/docker-compose.yml'"
  community.docker.docker_compose:
    project_name: "{{ service_cfg.name }}"
    project_src: "{{ service_cfg.directory }}"
    state: "{{ docker_compose_params.state }}"
    restarted: "{{ docker_compose_params.restarted }}"
    stopped: "{{ docker_compose_params.stopped }}"
    recreate: "{{ docker_compose_params.recreate }}"
    remove_orphans: "{{ docker_compose_params.remove_orphans }}"
    remove_volumes: "{{ docker_compose_params.remove_volumes }}"
  register: service_stack
  tags: [always]

```

I always get the following error:  
`fatal: [192.168.178.51]: FAILED! => {"changed": false, "msg": "Unable to load docker-compose. Try`pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/tmp/ansible_community.docker.docker_compose_payload_4k9kgich/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\", line 522, in <module>\nModuleNotFoundError: No module named 'compose'\n"}`

I have checked and tried many things but nothing gave me a hint.

This is an info starting the playbook with -vvv  
`<192.168.178.51> (1, b'\r\n{"failed": true, "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\\n File \\"/tmp/ansible_community.docker.docker_compose_payload_bgr20y5g/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\\", line 522, in <module>\\nModuleNotFoundError: No module named \'compose\'\\n", "invocation": {"module_args": {"project_name": "watchtower", "project_src": "/docker/watchtower", "state": "present", "restarted": false, "stopped": false, "recreate": "smart", "remove_orphans": false, "remove_volumes": false, "docker_host": "unix://var/run/docker.sock", "api_version": "auto", "tls": false, "use_ssh_client": false, "validate_certs": false, "debug": false, "hostname_check": false, "build": false, "dependencies": true, "pull": false, "nocache": false, "tls_hostname": null, "timeout": null, "ca_cert": null, "client_cert": null, "client_key": null, "ssl_version": null, "env_file": null, "files": null, "profiles": null, "definition": null, "remove_images": null, "scale": null, "services": null}}}\r\n', b'Shared connection to 192.168.178.51 closed.\r\n')`

This happens independently of the docker-compse.yml I wish to create: watchtower, traefik …

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [January 29, 2024, 5:37pm UTC](https://forum.ansible.com/t/community-docker-docker-compose/3519/2 "2024-01-29T17:37:57Z")

</div>

It looks to me that you have `docker compose` and you are using the [module for docker-compose](https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_module.html) when you should be using the new [docker compose module](https://docs.ansible.com/ansible/devel/collections/community/docker/docker_compose_v2_module.html).

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 29, 2024, 5:45pm UTC](https://forum.ansible.com/t/community-docker-docker-compose/3519/3 "2024-01-29T17:45:59Z")

</div>

Alternatively, you can read the error message, particularly the `pip install docker-compose` part, which _does_ give you a hint what you could do 😉

But I agree with @chris, better use the new `docker_compose_v2` module and don’t start caring about the docker-compose v1 Python package…

---

<div class="post-metadata">

**Author:** ![RoFrie](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@RoFrie](https://forum.ansible.com/u/RoFrie)\
**Post date:** [January 30, 2024, 6:25am UTC](https://forum.ansible.com/t/community-docker-docker-compose/3519/4 "2024-01-30T06:25:35Z")

</div>

Thx. I’ll will give it a try.
