解决ansible出现docker.APIClient\nAttributeError: \‘module\’ object has no attribute \'APIClient等问题。
fatal: [compute02]: FAILED! => {“changed”: true, “msg”: “‘Traceback (most recent call last):\n File “/tmp/ansible_kolla_docker_payload_VzuZuK/main.py”, line 1023, in main\n dw = DockerWorker(module)\n File “/tmp/ansible_kolla_docker_payload_VzuZuK/main.py”, line 265, in init\n self.dc = get_docker_client()(**options)\n File “/tmp/ansible_kolla_docker_payload_VzuZuK/main.py”, line 245, in get_docker_client\n return docker.APIClient\nAttributeError: \‘module\’ object has no attribute \‘APIClient\’\n’”}
# 从版本1.10.6(docker-py)到2.0.0(docker)的重大更改(和新功能)可以在docker-py文档中找到。
# 主要的变化是:
# docker.Client has been renamed to docker.APIClient
# docker.from_env now creates a DockerClient instance instead of an APIClient instance
# create_host_config, create_ipam_pool and create_ipam_config have been removed from docker.utils.
# They have been replaced by the following classes in docker.types: HostConfig, IPAMPool and IPAMCOnfig.
# (new feature) Added a high-level, user-focused API as docker.DockerClient
# docker.Client已重命名为docker.APIClient
# docker.from_env现在创建一个DockerClient实例而不是APIClient实例
# 已从docker.utils中删除create_host_config,create_ipam_pool和create_ipam_config。
# 它们已被docker.types中的以下类替换:HostConfig,IPAMPool和IPAMCOnfig。
# 新功能,添加了一个高级的,以用户为中心的API作为docker.DockerClient
pip2 uninstall docker-py
pip2 uninstall docker
# pip2 install "docker-py==1.10.6"
pip2 install "dockerpty==0.4.1"
pip2 install "docker-pycreds==0.4.0"
pip2 install "docker==4.4.4"