docker-compose在以普通用户身份运行时给出错误“ImportError:没有名为ssl_match_hostname的模块”

时间:2017-03-31 18:28:59

标签: python docker pip docker-compose

我已经使用'pip2.7 install docker-compose'安装了docker-compose但是当我尝试将其作为'普通'用户运行时,我收到以下错误消息:

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

此用户是docker组的一部分,可以毫无问题地运行“docker ps”等。

如果我尝试运行'sudo docker-compose -v',我会收到同样的错误。

但是,如果我首先运行'sudo su - '然后发出'docker-compose -v',我会得到预期的输出。

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

我为docker-compose,ssl_match_hostname的各种部分尝试了'pip uninstall',然后重新安装,但似乎没有解决它。

我现在彻底陷入困境 - 那里有任何想法吗?

2 个答案:

答案 0 :(得分:6)

你必须使用这个命令重新安装docker-compose:

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

它对我有用

答案 1 :(得分:-1)

也为我工作。

问题 root @ ashish:/ DOCKER#docker-compose -v 追溯(最近一次通话): 文件“ / usr / local / bin / docker-compose”,第5行,在 从compose.cli.main导入main ModuleNotFoundError:没有名为“ compose”的模块

解决方案

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

执行上述命令后,输出应如下所示。

root @ ashish:/ DOCKER#docker-compose -v docker-compose版本1.13.0,内部版本1719ceb

谢谢 阿什什贾(Ashish Jha)