10

I've installed docker-compose with 'pip2.7 install docker-compose" but when I try to run it as 'normal' user I get the following error message:

mike@hugin:~/Tobedeleted$ docker-compose  -v
Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 7, in <module>
    from compose.cli.main import main
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 17, in <module>
    from . import errors
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/errors.py", line 10, in <module>
    from docker.errors import APIError
  File "/usr/local/lib/python2.7/dist-packages/docker/__init__.py", line 2, in <module>
    from .api import APIClient
  File "/usr/local/lib/python2.7/dist-packages/docker/api/__init__.py", line 2, in <module>
    from .client import APIClient
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 11, in <module>
    from .build import BuildApiMixin
  File "/usr/local/lib/python2.7/dist-packages/docker/api/build.py", line 9, in <module>
    from .. import utils
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/__init__.py", line 2, in <module>
    from .build import tar, exclude_paths
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/build.py", line 4, in <module>
    from .utils import create_archive
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/utils.py", line 18, in <module>
    from .. import tls
  File "/usr/local/lib/python2.7/dist-packages/docker/tls.py", line 5, in <module>
    from .transport import SSLAdapter
  File "/usr/local/lib/python2.7/dist-packages/docker/transport/__init__.py", line 3, in <module>
    from .ssladapter import SSLAdapter
  File "/usr/local/lib/python2.7/dist-packages/docker/transport/ssladapter.py", line 21, in <module>
    from backports.ssl_match_hostname import match_hostname
ImportError: No module named ssl_match_hostname

This user is part of the docker group and can run 'docker ps' etc without any issue.

If I try to run 'sudo docker-compose -v' I get the same error.

However, if I run 'sudo su -' first and then issue 'docker-compose -v' I get the expected output.

root@hugin:~# docker-compose -v
docker-compose version 1.11.2, build dfed245

I've tried 'pip uninstall' for various, and all, parts of docker-compose, ssl_match_hostname and then reinstall but nothing seems to resolve it.

I'm now thoroughly stuck - any ideas out there?

Swedish Mike
  • 583
  • 1
  • 8
  • 23

7 Answers7

26

you have to reinstall docker-compose using this command:

curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

it worked for me

user692727
  • 386
  • 4
  • 3
  • 2
    I also had to 1/ uninstall docker-compose first and 2/run ```sudo rm /home/myName/.local/bin/docker-compose``` (as it conflicted in my path name) And for a up-to-date install (and uninstall) instructions see here: https://docs.docker.com/compose/install/ – Sofien Nov 26 '20 at 07:58
  • 1
    see latest release at https://github.com/docker/compose/releases – Scott Stensland Jul 17 '21 at 10:36
  • @SofienM it is recommended to get the installation command from https://docs.docker.com/compose/install/ and currently the latest version is 1.29.2 – thanos.a Dec 20 '21 at 13:32
  • Permanent latest version URL: `https://github.com/docker/compose/releases/latest/download/docker-compose-\`uname -s\`-\`uname -m\`` – IGHOR Apr 23 '22 at 09:09
6

you should check if docker-compose exist, is installed and running:

$ whereis docker-compose
$ docker-compose --version

check if exist symbolic link pip -> pip2.7 or pip -> pip3.6 by running:

$ sudo pip install docker-compose
Kristian
  • 2,456
  • 8
  • 23
  • 23
TOR
  • 71
  • 1
  • 4
2

This happened to me after updating to Python 3.10. I fixed it by reinstalling docker-compose with:

pip install docker-compose

Note: running yay -S docker-compose on Manjaro didn't work for me.

Gabriel Ziegler
  • 361
  • 3
  • 18
1

Docker Compose now runs as a Docker plugin. I recommend using:

sudo apt-get install docker-compose-plugin

And then use docker compose instead of docker-compose

Aleksander Lech
  • 1,105
  • 12
  • 16
-1

Check the permission on the remote host where the ansible jobs are getting executed.

Make sure the "other" users have the execute permission of the module packages.

sudo chmod -R  o=rx /usr/local/lib/python2.7/dist-packages/
ninohead
  • 325
  • 2
  • 6
-1

Firstly check if you have the docker sock file under /var/run/.

# ls -l /var/run/docker.sock
# docker info

If the file doesn't exist, then restart the docker service. If it still doesn't exist, restart the node and see if you have the file.

ninohead
  • 325
  • 2
  • 6
-3

Also worked for me.

Issue root@ashish:/DOCKER# docker-compose -v Traceback (most recent call last): File "/usr/local/bin/docker-compose", line 5, in from compose.cli.main import main ModuleNotFoundError: No module named 'compose'

Solution

curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-uname -s-uname -m > /usr/local/bin/docker-compose

After executed above command, Output should be look like given below.

root@ashish:/DOCKER# docker-compose -v docker-compose version 1.13.0, build 1719ceb

Thanks Ashish Jha