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
deb http://mirrors.aliyun.com/debian stretch-proposed-updates main contrib non-free
deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib
'
> /etc/apt/sources.list
&& apt-get update
# 配置pip
RUN mkdir /root/.pip
&& echo '[global]
trusted-host = mirrors.aliyun.com
index-url = https://mirrors.aliyun.com/pypi/simple
'
> /root/.pip/pip.conf