Need help?

Our experts have had an average response time of 11.7 minutes in August 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

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”}

 

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
~~~~

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
~~~

Python 2.7 version :

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

For Python 2.6 :

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

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.

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

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF