Bobcares

Ansible No module named ‘docker’ error

by | Jul 2, 2021

Stuck with Ansible No module named ‘docker’ error? We can help you.

Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code.

As part of our Server Management Services, we assist our customers with several Ansible queries.

Today, let us see how we can fix this error.

 

Ansible No module named ‘docker’ error

Typical error will look as shown below:

PLAY [server1.lab.com] ***********************************************************************************************************************

TASK [Create a data container] ***************************************************************************************************************
fatal: [server1.lab.com]: FAILED! => {“ansible_facts”: {“discovered_interpreter_python”: “/usr/bin/python”}, “changed”: false, “msg”: “Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on bac4681b1d1c.mylabserver.com’s Python /usr/bin/python. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named docker”}Copy Code

 

What causes no module named ‘docker’ error?

Let us see what causes this error.

Ansible uses python to deploy changes in the target machine.

Because of that any module you use in Ansible will require a respective python library in the target machine to work.

For the Docker module in Ansible to work, the target machine must have the Docker SDK, which is a Python library used to manage Docker from a python application.

 

How to resolve it?

Today, let us go through the steps followed by our Support Techs to resolve this error.

To fix this error, the Docker SDK library for python must be installed on the target machine.

But before installing you need to identify the python version in the target machine.

~~~~
$ python –version
Python 3.8.5
~~~~Copy Code

The python version in that machine is Python 3.8.5. For Python 3.6 or later versions, the following command can used to install the Docker SDK library :

~~~
$ pip install docker
~~~Copy Code

Python 2.7 version :

~~~
$ pip install ‘docker==4.4.4’
~~~Copy Code

For Python 2.6 :

~~~
$ pip install ‘docker-py>=1.10.0’
~~~Copy Code

The problem should disappear once we install docker SDK library at the target machine.

 

[Still, stuck with the Ansible error? Let us take a look into it]

 

Conclusion

In short, we saw how our Support Techs fix the Ansible error for our customers.

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Speed issues driving customers away?
We’ve got your back!