love迅雷下载,婚礼司仪台词,浣花洗剑录txt下载
docker提供了python、go等编程语言的api。最近打算用docker sdk for python(以下简称docker-py)做点东西,本来以为按照官网上的步骤安装很简单,pip install docker 就行,然而出现了版本不兼容的问题。
报错如下:
docker.errors.apierror: 400 client error: bad request ("client is newer than server (client api version: 1.30, server api version: 1.19)")
可以使用指令 docker version查看版本号,果然api版本是1.19,但是docker-py的版本是1.30。在官网 里找一找解决方法,from_env()的解释如下:
from_env() return a client configured from environment variables. the environment variables used are the same as those used by the docker command-line client. they are: docker_host the url to the docker host. docker_tls_verify verify the host against a ca certificate. docker_cert_path a path to a directory containing tls certificates to use when connecting to the docker host. parameters: version (str) – the version of the api to use. set to auto to automatically detect the server's version. default: 1.26 timeout (int) – default timeout for api calls, in seconds. ssl_version (int) – a valid ssl version. assert_hostname (bool) – verify the hostname of the server. environment (dict) – the environment to read environment variables from. default: the value of os.environ
有一个参数可以指定version,于是这样写:client=docker.from_env(version='1.19') 似乎就能避免版本不兼容的问题了。然而还是报错:
valueerror: zero length field name in format
搜了一下这是因为我的python版本是2.6,在对参数解析时出现格式问题,没办法,只好升级python2.7了。
在官网的change日志中可以看到,2.0版本之后就不再支持python2.6了。
2.0.0 ... breaking changes dropped support for python 2.6
将python2.6升级到2.7,不仅要编译安装python2.7,还要把/usr/local/bin/pip2.7软连接给/usr/bin/pip 以覆盖原来的pip2.6,然后重新pip install docker
如果是centos系统,不要忘了修改/usr/bin/yum ,将第一行#!/usr/bin/python 改为#!/usr/bin/python2.6 ,否则yum指令无法使用。
以上这篇快速解决docker-py api版本不兼容的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python 实现将numpy中的nan和inf,nan替换成对应的均值
python爬虫把url链接编码成gbk2312格式过程解析
网友评论