由于连接超时错误,无法构建 docker 镜像

时间:2021-02-23 23:25:23

标签: docker

我无法构建我的 docker 镜像,因为它不断出现超时错误。我在一个不允许 http 连接的系统上工作。我尝试在 Dockerfile 中使用 HTTP_PROXYHTTPS_PROXY 环境变量,但没有帮助。

Dockerfile

FROM conda/miniconda3:latest

RUN mkdir mlflow

WORKDIR /mlflow
   
RUN apt-get update && apt-get install -y \
    build-essential \
    python3-dev \
    libpq-dev

RUN pip install -U pip && \
    pip install psycopg2 mlflow boto3


EXPOSE 5000

CMD mlflow server \
    --host 0.0.0.0 \
    --port 5000 \
    --backend-store-uri "postgresql+psycopg2://{USERNAME}:{PASSWORD}@postgresql:5432/mlflowdb" \
    --default-artifact-root "s3://bucket-eb84c612/"

错误

W: Failed to fetch http://deb.debian.org/debian/dists/stretch/InRelease  Could not connect to 151.101.210.132:80 (151.101.210.132), connection timed out
W: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/InRelease  Could not connect to 151.101.210.132:80 (151.101.210.132), connection timed out
W: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/InRelease  Unable to connect to 151.101.210.132:80:

1 个答案:

答案 0 :(得分:0)

我终于修复了它!

FROM python:3.7-slim

RUN printf "deb https://deb.debian.org/debian buster main \n deb https://deb.debian.org/debian buster-updates main" > /etc/apt/sources.list

RUN pip3 install awscli

# need gcc to compile psycopg2
RUN apt-get update && apt-get install -y libpq-dev gcc

RUN apt-get update \
&& apt-get install libpq-dev gcc -y \
&& apt-get clean

RUN pip3 --no-cache-dir install \
    mlflow==1.14.0 \
    psycopg2~=2.8.6  \ 
    boto3

RUN apt-get autoremove -y gcc

RUN mkdir /mlflow/

WORKDIR /mlflow

EXPOSE 8001

CMD mlflow server \
    --host 0.0.0.0 \
    --port 8001 \
    --backend-store-uri "postgresql+psycopg2://{username}:{password}@{hostname}:5432/mlflowdb" \
    --default-artifact-root "s3://bucket-eb84c6b0/"