一、问题现象
构建镜像时,使用pip命令打包报错:
二、问题根因
因国内无法访问pip的配置文件中的仓库地址
三、解决办法
这个办法同样适用于:物理机,这个地址是阿里云的
- pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
- pip config set install.trusted-host mirrors.aliyun.com
- FROM python:3.8
-
- COPY . /app
- RUN pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
- RUN pip config set install.trusted-host mirrors.aliyun.com
- WORKDIR /app
-
- RUN pip install flask
-
- CMD ["python", "app.py"]
四、其他仓库地址