# pip docker install

**URL:** <https://forum.ansible.com/t/pip-docker-install/31407>\
**Category:** Ansible Project\
**Created:** [October 2, 2019, 8:36am UTC](https://forum.ansible.com/t/pip-docker-install/31407 "2019-10-02T08:36:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alfredo\_De\_Luca](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@Alfredo\_De\_Luca](https://forum.ansible.com/u/Alfredo_De_Luca)\
**Post date:** [October 2, 2019, 8:36am UTC](https://forum.ansible.com/t/pip-docker-install/31407/1 "2019-10-02T08:36:30Z")

</div>

Hi all.

I have the following…

- name: Install pip  
package:  
name: python-pip  
update\_cache: true  
state: present

- name: Install docker libs with pip  
pip:  
name: docker  
state: present  
executable: pip

When I run the playbook the first time it fails with  
  
**FAILED! =\> {“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 myhost 's Python /usr/bin/python3. Please read module documentation and install in the appropriate location, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named ‘docker’”}**

But if ti runs the second time no issue at all.  
Any idea why? I thought it was cause it can’t find the path for PIP … but not sure.  
Cheers

---

<div class="post-metadata">

**Author:** ![Ravi\_Ranjan](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@Ravi\_Ranjan](https://forum.ansible.com/u/Ravi_Ranjan)\
**Post date:** [October 2, 2019, 9:59am UTC](https://forum.ansible.com/t/pip-docker-install/31407/2 "2019-10-02T09:59:41Z")

</div>

Hi Luca ,

I have observed the same for our GCP instances where i am running docker on VM . Then, i had to uninstall via “pip uninstall docker” and then re-install it - “pip install docker” . Issues get resolved .

Ravi Ranjan

---

<div class="post-metadata">

**Author:** ![Alfredo\_De\_Luca](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@Alfredo\_De\_Luca](https://forum.ansible.com/u/Alfredo_De_Luca)\
**Post date:** [October 2, 2019, 1:50pm UTC](https://forum.ansible.com/t/pip-docker-install/31407/3 "2019-10-02T13:50:17Z")

</div>

Hi Ravi. I ve done that but didn’t work.

It seems to have problem finding the package pip rather than the docker library itself.

---

<div class="post-metadata">

**Author:** ![Ravi\_Ranjan](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@Ravi\_Ranjan](https://forum.ansible.com/u/Ravi_Ranjan)\
**Post date:** [October 2, 2019, 3:31pm UTC](https://forum.ansible.com/t/pip-docker-install/31407/4 "2019-10-02T15:31:05Z")

</div>

After uninstall via “pip uninstall docker” and then use “pip install docker --upgrade” , if that also didnt work - u need to un-install docker-compose as well “pip uninstall docker-compose” , it should work then

This issue happened to me last week in production

---

<div class="post-metadata">

**Author:** ![Alfredo\_De\_Luca](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@Alfredo\_De\_Luca](https://forum.ansible.com/u/Alfredo_De_Luca)\
**Post date:** [October 2, 2019, 3:37pm UTC](https://forum.ansible.com/t/pip-docker-install/31407/5 "2019-10-02T15:37:01Z")

</div>

ok thanks I will give it a try

cheers

---

<div class="post-metadata">

**Author:** ![Ravi\_Ranjan](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@Ravi\_Ranjan](https://forum.ansible.com/u/Ravi_Ranjan)\
**Post date:** [October 2, 2019, 3:48pm UTC](https://forum.ansible.com/t/pip-docker-install/31407/6 "2019-10-02T15:48:18Z")

</div>

These steps needs to be done on the remote machine

1. pip uninstall docker2) pip list | grep docker
2. pip uninstall docker-compose
3. pip install docker --upgrade

This should work

---

<div class="post-metadata">

**Author:** ![P\_Varsha](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@P\_Varsha](https://forum.ansible.com/u/P_Varsha)\
**Post date:** [October 3, 2019, 5:52am UTC](https://forum.ansible.com/t/pip-docker-install/31407/7 "2019-10-03T05:52:01Z")

</div>

hello,

check once from command prompt **_pip install docker_** under the python scripts folder it will work.

thanks,  
varsha

---

<div class="post-metadata">

**Author:** ![Alfredo\_De\_Luca](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@Alfredo\_De\_Luca](https://forum.ansible.com/u/Alfredo_De_Luca)\
**Post date:** [October 3, 2019, 5:42pm UTC](https://forum.ansible.com/t/pip-docker-install/31407/8 "2019-10-03T17:42:31Z")

</div>

still doesn’t work. everything I do the first time doesn’t work and the second time it does…

very very weird…

---

<div class="post-metadata">

**Author:** ![P\_Varsha](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@P\_Varsha](https://forum.ansible.com/u/P_Varsha)\
**Post date:** [October 4, 2019, 5:10am UTC](https://forum.ansible.com/t/pip-docker-install/31407/9 "2019-10-04T05:10:02Z")

</div>

can you share the screenshot if is it possible?.i tell u in better way

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [October 4, 2019, 7:29am UTC](https://forum.ansible.com/t/pip-docker-install/31407/10 "2019-10-04T07:29:37Z")

</div>

> still doesn't work. everything I do the first time doesn't work and the second time it does....
> 
> very very weird...

Can you provide OS and release information about the target?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Alfredo\_De\_Luca](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@Alfredo\_De\_Luca](https://forum.ansible.com/u/Alfredo_De_Luca)\
**Post date:** [October 4, 2019, 9:56am UTC](https://forum.ansible.com/t/pip-docker-install/31407/11 "2019-10-04T09:56:25Z")

</div>

Hi Stefan.

Here is my vagrant file  
(1…3).each do |i|  
config.vm.define “iri-0#{i}” do |node|  
node.vm.box = “ubuntu/bionic64”  
node.vm.box\_version = “20190918.0.0”  
node.vm.network “private\_network”, ip: “#{SUBNET}.1#{i}”  
node.vm.hostname = “imi-0#{i}”  
node.vm.provider :virtualbox do |v|  
v.cpus = 3  
v.memory = 3072  
end  
end  
end

So basically is Ubuntu Bionic Vm create with Virtualbox

Alfredo
