# Ansible Docker command is not working

**URL:** <https://forum.ansible.com/t/ansible-docker-command-is-not-working/35432>\
**Category:** Ansible Project\
**Created:** [June 29, 2021, 1:35am UTC](https://forum.ansible.com/t/ansible-docker-command-is-not-working/35432 "2021-06-29T01:35:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajaniesh\_Kaushikk](https://avatars.discourse-cdn.com/v4/letter/r/6de8d8/32.png) [@Rajaniesh\_Kaushikk](https://forum.ansible.com/u/Rajaniesh_Kaushikk)\
**Post date:** [June 29, 2021, 1:35am UTC](https://forum.ansible.com/t/ansible-docker-command-is-not-working/35432/1 "2021-06-29T01:35:24Z")

</div>

Hi,

I am trying to run a service via ansible

- name: Run airflow init  
shell:  
cmd: docker-compose up airflow-init  
chdir: /home/azureuser/airflow

but it is throwing this error:

fatal: [dmpServer]: FAILED! =\> {“changed”: true, “cmd”: “docker-compose up airflow-init”, “delta”: “0:00:01.016183”, “end”: “2021-06-29 01:26:01.836135”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2021-06-29 01:26:00.819952”, “stderr”: “/usr/local/lib/python2.7/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.\n from cryptography.hazmat.backends import default\_backend\nThe Compose file ‘./docker-compose.yaml’ is invalid because:\nInvalid top-level property "x-airflow-common". Valid top-level sections for this Compose file are: services, version, networks, volumes, and extensions starting with "x-".\n\nYou might be seeing this error because you’re using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.\nFor more on the Compose file format versions, see [https://docs.docker.com/compose/compose-file/\nservices.airflow-init.depends\_on](https://docs.docker.com/compose/compose-file/%5Cnservices.airflow-init.depends_on) contains an invalid type, it should be an array\nservices.airflow-scheduler.depends\_on contains an invalid type, it should be an array\nservices.airflow-webserver.depends\_on contains an invalid type, it should be an array\nservices.airflow-worker.depends\_on contains an invalid type, it should be an array\nservices.flower.depends\_on contains an invalid type, it should be an array”, “stderr\_lines”: [“/usr/local/lib/python2.7/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.”, " from cryptography.hazmat.backends import default\_backend", “The Compose file ‘./docker-compose.yaml’ is invalid because:”, “Invalid top-level property "x-airflow-common". Valid top-level sections for this Compose file are: services, version, networks, volumes, and extensions starting with "x-".”, “”, “You might be seeing this error because you’re using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.”, “For more on the Compose file format versions, see [https://docs.docker.com/compose/compose-file/](https://docs.docker.com/compose/compose-file/)”, “services.airflow-init.depends\_on contains an invalid type, it should be an array”, “services.airflow-scheduler.depends\_on contains an invalid type, it should be an array”, “services.airflow-webserver.depends\_on contains an invalid type, it should be an array”, “services.airflow-worker.depends\_on contains an invalid type, it should be an array”, “services.flower.depends\_on contains an invalid type, it should be an array”], “stdout”: “”, “stdout\_lines”: }

Even though I have installed Python 3.

root@dmpVM:airflow# python3 -V  
Python 3.6.9

How to resolve this issue?

Regards  
Rajaniesh

---

<div class="post-metadata">

**Author:** ![Roberto\_J\_R\_Paz](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@Roberto\_J\_R\_Paz](https://forum.ansible.com/u/Roberto_J_R_Paz)\
**Post date:** [June 29, 2021, 1:52am UTC](https://forum.ansible.com/t/ansible-docker-command-is-not-working/35432/2 "2021-06-29T01:52:14Z")

</div>

It seems there is an error in **docker-compose.yml** file (Invalid top-level property “x-airflow-common”). Have you tried to run docker-compose manually on remote server?

---

<div class="post-metadata">

**Author:** ![Ben\_Sikkens](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@Ben\_Sikkens](https://forum.ansible.com/u/Ben_Sikkens)\
**Post date:** [June 29, 2021, 5:35am UTC](https://forum.ansible.com/t/ansible-docker-command-is-not-working/35432/3 "2021-06-29T05:35:09Z")

</div>

You should also consider using the docker-compose module.

[https://docs.ansible.com/ansible/latest/collections/community/docker/docker\_compose\_module.html#ansible-collections-community-docker-docker-compose-module](https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_module.html#ansible-collections-community-docker-docker-compose-module)
