简体   繁体   中英

Unable to build docker image due to connection timeout error

I'm unable to build my docker image as it keeps erroring out with a timeout error. I'm working on a system that doesn't allow http connection. I tried using HTTP_PROXY & HTTPS_PROXY environment variables in the Dockerfile but it didn't help.

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/"

Error

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:

I was able to fix it finally!

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/"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM