Dockerfile里pip.conf报错ConfigParser.MissingSectionHeaderError: File contains no section headers.


Dockerfile的部分内容如下:

RUN mkdir /root/.pip && echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > /root/.pip/pip.conf
RUN pip install PyCryptodome

目测是没有问题,可是docker build的时候就报错:

ConfigParser.MissingSectionHeaderError: File contains no section headers.

惊讶,然后尝试打印pip.conf的内容:

-e [global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

发现-e竟然进入到文件内容里,诡异。

最后发现去掉-e就可以,而且Dockerfile的echo不加-e参数也可以识别转义字符。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM