当前位置: 首页 > 工具软件 > docker-client > 使用案例 >

【docker-compose up 失败】

邹宣
2023-12-01

错误1

docker-compose up Traceback (most recent call last): File "/home/xuyuandong/.local/bin/docker-compose", line 33, in <module> sys.exit(load_entry_point('docker-compose==1.4.2', 'console_scripts', 'docker-compose')()) File "/home/xuyuandong/.local/bin/docker-compose", line 25, in importlib_load_entry_point return next(matches).load() File "/usr/local/lib/python3.10/importlib/metadata/__init__.py", line 162, in load module = import_module(match.group('module')) File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/main.py", line 10, in <module> from docker.errors import APIError File "/home/xuyuandong/.local/lib/python3.10/site-packages/docker/__init__.py", line 20, in <module> from .client import Client, AutoVersionClient # flake8: noqa File "/home/xuyuandong/.local/lib/python3.10/site-packages/docker/client.py", line 23, in <module> from . import clientbase File "/home/xuyuandong/.local/lib/python3.10/site-packages/docker/clientbase.py", line 4, in <module> import requests File "/home/xuyuandong/.local/lib/python3.10/site-packages/requests/__init__.py", line 58, in <module> from . import utils File "/home/xuyuandong/.local/lib/python3.10/site-packages/requests/utils.py", line 26, in <module> from .compat import parse_http_list as _parse_list_header File "/home/xuyuandong/.local/lib/python3.10/site-packages/requests/compat.py", line 7, in <module> from .packages import chardet File "/home/xuyuandong/.local/lib/python3.10/site-packages/requests/packages/__init__.py", line 3, in <module> from . import urllib3 File "/home/xuyuandong/.local/lib/python3.10/site-packages/requests/packages/urllib3/__init__.py", line 10, in <module> from .connectionpool import ( File "/home/xuyuandong/.local/lib/python3.10/site-packages/requests/packages/urllib3/connectionpool.py", line 38, in <module> from .response import HTTPResponse File "/home/xuyuandong/.local/lib/python3.10/site-packages/requests/packages/urllib3/response.py", line 9, in <module> from ._collections import HTTPHeaderDict File "/home/xuyuandong/.local/lib/python3.10/site-packages/requests/packages/urllib3/_collections.py", line 1, in <module>
原因:
requests 版本太老了 升级一下

错误2

docker-compose up Traceback (most recent call last): File "/home/xuyuandong/.local/bin/docker-compose", line 8, in <module> sys.exit(main()) File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/main.py", line 81, in main command_func() File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/main.py", line 200, in perform_command project = project_from_options('.', options) File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/command.py", line 60, in project_from_options return get_project( File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/command.py", line 144, in get_project config_details = config.find(project_dir, config_path, environment, override_dir) File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/config/config.py", line 330, in find [ConfigFile.from_filename(f) for f in filenames], File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/config/config.py", line 330, in <listcomp> [ConfigFile.from_filename(f) for f in filenames], File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/config/config.py", line 196, in from_filename return cls(filename, load_yaml(filename)) File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/config/config.py", line 1489, in load_yaml return yaml.safe_load(fh) File "/home/xuyuandong/.local/lib/python3.10/site-packages/yaml/__init__.py", line 94, in safe_load return load(stream, SafeLoader) File "/home/xuyuandong/.local/lib/python3.10/site-packages/yaml/__init__.py", line 72, in load return loader.get_single_data() File "/home/xuyuandong/.local/lib/python3.10/site-packages/yaml/constructor.py", line 37, in get_single_data return self.construct_document(node) File "/home/xuyuandong/.local/lib/python3.10/site-packages/yaml/constructor.py", line 46, in construct_document for dummy in generator: File "/home/xuyuandong/.local/lib/python3.10/site-packages/yaml/constructor.py", line 398, in construct_yaml_map value = self.construct_mapping(node) File "/home/xuyuandong/.local/lib/python3.10/site-packages/yaml/constructor.py", line 204, in construct_mapping return super().construct_mapping(node, deep=deep) File "/home/xuyuandong/.local/lib/python3.10/site-packages/yaml/constructor.py", line 126, in construct_mapping if not isinstance(key, collections.Hashable): AttributeError: module 'collections' has no attribute 'Hashable'
原因
yaml的版本太老了
升级 pip install PyYAML==5.4.1

错误3

docker-compose up ERROR: The Compose file './docker-compose.yaml' is invalid because: services.mongo.volumes contains an invalid type, it should be an array [xuyuandong@10-9-51-41 workspace]$ docker-compose up Traceback (most recent call last): File "/home/xuyuandong/.local/bin/docker-compose", line 8, in <module> sys.exit(main()) File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/main.py", line 81, in main command_func() File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/main.py", line 200, in perform_command project = project_from_options('.', options) File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/command.py", line 60, in project_from_options return get_project( File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/command.py", line 152, in get_project client = get_client( File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/docker_client.py", line 41, in get_client client = docker_client( File "/home/xuyuandong/.local/lib/python3.10/site-packages/compose/cli/docker_client.py", line 170, in docker_client client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs) File "/home/xuyuandong/.local/lib/python3.10/site-packages/docker/api/client.py", line 131, in __init__ self._auth_configs = auth.load_config( TypeError: load_config() got an unexpected keyword argument 'config_dict'

原因
docke-py 版本太老了
pip list

Package            Version
------------------ ---------
attrs              21.4.0
bcrypt             3.2.0
certifi            2021.10.8
cffi               1.15.0
charset-normalizer 2.0.12
cryptography       36.0.1
distro             1.7.0
`docker             5.0.3`
docker-compose     1.29.2
`docker-py          1.3.1`
dockerpty          0.4.1
docopt             0.6.2
idna               3.3
jsonschema         3.2.0
paramiko           2.9.2
pip                22.0.3
pycparser          2.21
PyNaCl             1.5.0
pyrsistent         0.18.1
python-dotenv      0.19.2
PyYAML             5.4.1
requests           2.27.1
setuptools         58.1.0
six                1.16.0
texttable          1.6.4
urllib3            1.26.8
websocket-client   0.59.0

同时 无论怎么升级 好像都有点问题 ,就是up不起来
仔细看会发现即有docker也有docker-py, docker-compose在安装的时候只依赖了一个。
所以干docker-py就ok了!

 类似资料: