pip docker install

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

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

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.

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

ok thanks I will give it a try

cheers

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

hello,

check once from command prompt pip install docker under the python scripts folder it will work.

thanks,
varsha

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

very very weird…

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

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
        Racke

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