Docker镜像在CentOS中失败,但在MacOS上工作

我正在使用下面的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 

不知道为什么它使用17.09.0-ce在MacOS上正常工作,但是没有使用CentOS和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' 

任何想法为什么相同的图像不能跨越不同的操作系统build立? 此外,我尝试使用Ubuntu作为docker的形象,并在两个完美的作品。 谢谢。

这个错误是由epel-release安装的chardet软件包与epel软件包列表之间的冲突引起的,该软件包与特定版本的pyvmomi所需的软件包相pyvmomi

使用OS软件包版本来避免这种冲突,例如yum -q install python2-pyvmomi

这个错误的非确定性外观将归因于epel-release中的package verion上游的变化以及pip install