Dockerfile中echo使用


Dockerfile 中的echo的使用方式和bash中的使用方式是有区别的
下面是一个 Dockerfile 通过echo的方式更换apt-get源和pip

FROM python:3.5.8-stretch

# 更新缓存
RUN echo 'deb http://mirrors.aliyun.com/debian stretch main contrib non-free\n\
deb http://mirrors.aliyun.com/debian stretch-proposed-updates main contrib non-free\n\
deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free\n\
deb http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib\n'\
> /etc/apt/sources.list \
&& apt-get update

# 配置pip
RUN mkdir /root/.pip \
&& echo '[global]\n\
trusted-host = mirrors.aliyun.com\n\
index-url = https://mirrors.aliyun.com/pypi/simple\n'\
> /root/.pip/pip.conf

参考:Multiline Dockerfile syntax


免责声明!

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



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