解决Docker构建时出现的 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: Permission denied
在根据官网的Docker-compose构建示例项目时遇到的问题,原因是因为无法访问官网给出的外网镜像,可能还会出现
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: network error
通过在Dockerfile中引入下面两个命令可以解决该问题:
RUN sed -i ‘s/https/http/’ /etc/apk/repositories
RUN apk add curl
完整的Dockerfile文件示例:
FROM python:3.7-alpine
RUN sed -i 's/https/http/' /etc/apk/repositories
RUN apk add curl
WORKDIR /code
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
RUN apk add --no-cache gcc musl-dev linux-headers
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
EXPOSE 5000
COPY . .
CMD [