Docker映像在CentOS中失败,但适用于MacOS

时间:2017-11-16 01:30:52

标签: python docker pip containers

我正在使用以下Dockerfile:

FROM centos
RUN yum -y -q install epel-release && yum -y -q update && yum clean all \
&& yum -y -q install python-pip
COPY requirements.txt /tmp/
RUN pip install -q pyvmomi==6.5.0.2017.5.post1

不确定为什么它在使用docker 17.09.0-ce的MacOS上运行正常,但它没有将CentOS与docker 17.11.0-ce-rc3一起使用。 pip安装中有一个错误,在这个例子中我使用pyvmomi但是我和其他包有类似的错误。

Step 3/3 : RUN pip install pyvmomi==6.5.0.2017.5.post1
 ---> Running in 49d94b300e7f
Collecting pyvmomi==6.5.0.2017.5.post1
  Downloading pyvmomi-6.5.0.2017.5-1.tar.gz (252kB)
Collecting requests>=2.3.0 (from pyvmomi==6.5.0.2017.5.post1)
  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
Collecting six>=1.7.3 (from pyvmomi==6.5.0.2017.5.post1)
  Downloading six-1.11.0-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests>=2.3.0->pyvmomi==6.5.0.2017.5.post1)
  Downloading certifi-2017.11.5-py2.py3-none-any.whl (330kB)
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.3.0->pyvmomi==6.5.0.2017.5.post1)
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
Collecting idna<2.7,>=2.5 (from requests>=2.3.0->pyvmomi==6.5.0.2017.5.post1)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
Collecting urllib3<1.23,>=1.21.1 (from requests>=2.3.0->pyvmomi==6.5.0.2017.5.post1)
  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
Installing collected packages: certifi, chardet, idna, urllib3, requests, six, pyvmomi
  Found existing installation: chardet 2.2.1
    Uninstalling chardet-2.2.1:
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 326, in run
    strip_file_prefix=options.strip_file_prefix,
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 736, in install
    requirement.uninstall(auto_confirm=True)
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/usr/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/usr/lib/python2.7/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/usr/lib64/python2.7/shutil.py", line 299, in move
    rmtree(src)
  File "/usr/lib64/python2.7/shutil.py", line 256, in rmtree
    onerror(os.rmdir, path, sys.exc_info())
  File "/usr/lib64/python2.7/shutil.py", line 254, in rmtree
    os.rmdir(path)
OSError: [Errno 39] Directory not empty: '/usr/lib/python2.7/site-packages/chardet'

知道为什么同一个图像无法在不同的操作系统上构建?此外,我尝试使用ubuntu作为docker镜像,并在两者中都很完美。 感谢。

1 个答案:

答案 0 :(得分:0)

错误是由chardet安装的epel-release软件包之间的冲突引起的 请参阅epel package list以及pyvmomi特定版本所需的版本。

使用操作系统软件包版本来避免此冲突,即yum -q install python2-pyvmomi

此错误的非确定性外观将归因于epel-release中的包版本中的上游更改以及pip install中使用的更改