在远程主机上构建Docker容器失败。

3
我有一套由yml文件生成的docker容器,目前运行良好。现在我想将它们部署到另一台机器上。在这里的另一篇文章中,我被建议使用以下两个选项之一在远程主机上构建容器:
1. 将代码复制到远程主机并应用修改后的docker-compose,在使用修改后的docker-compose从源代码构建容器。 2. 在本地机器上创建镜像,将其推送到docker存储库中,然后使用修改后的docker-compose从那里拉取。
我正在尝试遵循选项1(作为开始)。我将代码复制到了远程主机,并修改了Dockerfile.dair和docker-compose.yml文件(片段1)。构建过程进行了一半。它下载了python和postgres映像,并开始处理Dockerfile,但未能安装要求(无法安装第一个要求-见片段2)。可能是什么问题?
cat /home/ubuntu/webServer/web/Dockerfile.dair

FROM python:3.6.1
MAINTAINER User4 <user4@gmail.com>

# Create the group and user to be used in this container
RUN groupadd flaskgroup && useradd -m -g flaskgroup -s /bin/bash flask

# Create the working directory (and set it as the working directory)
RUN mkdir -p /home/flask/app/web
WORKDIR /home/flask/app/web

# Install the package dependencies (this step is separated
# from copying all the source code to avoid having to
# re-install all python packages defined in requirements2.txt
# whenever any source code change is made)
COPY requirements2.txt /home/flask/app/web
RUN pip install --no-cache-dir -r requirements2.txt

# Copy the source code into the container
COPY . /home/flask/app/web

RUN chown -R flask:flaskgroup /home/flask

USER flask

EXPOSE 8000

CMD /usr/local/bin/gunicorn -w 2 -t 3600 -b :8000 project:app

ENV PYTHONUNBUFFERED=1
ENV FLASK_APP=run.py
ENV FLASK_DEBUG=1

,

cat /home/ubuntu/construction_overlay/webServer/docker-compose.dair.yml
version: '3'

services:
  web:
    restart: always
    build:
      context: ./web
      dockerfile: Dockerfile.dair
    volumes:
      - /home/ubuntu/construction_overlay/webServer/web:/home/flask/app/web
    depends_on:
      - postgres

  nginx:
    restart: always
    build: ./nginx
    ports:
      - "80:80"
    volumes:
      - /home/ubuntu/construction_overlay/webServer/web:/home/flask/app/web
    depends_on:
      - web

  postgres:
    restart: always
    build: ./postgresql
    volumes:
      - data1:/var/lib/postgresql
    expose:
      - "5432"

volumes:
  data1:

snippet2 - 构建失败,无法安装需求

cat /home/ubuntu/webServer/web/requirements.txt
alembic==0.8.8
atomicwrites==1.3.0
attrs==19.1.0
...

,

docker-compose -f /home/ubuntu/webServer/docker-compose.dair.yml  up --build -d;
Building postgres
Step 1/4 : FROM postgres:11.3
 ---> 4e045cb8eecd
Step 2/4 : ENV POSTGRES_USER postgres_user
 ---> Using cache
 ---> 400023c58607
Step 3/4 : ENV POSTGRES_PASSWORD postgres_user
 ---> Using cache
 ---> 0cf91f314380
Step 4/4 : ENV POSTGRES_DB construction-overlay-db
 ---> Using cache
 ---> 151106ecf13b
Successfully built 151106ecf13b
Successfully tagged webserver_postgres:latest
Building web
Step 1/10 : FROM python:3.6.1
 ---> 955d0c3b1bb2
Step 2/10 : MAINTAINER User4 <user4@gmail.com>
 ---> Using cache
 ---> 128d55ddb4e7
Step 3/10 : RUN groupadd flaskgroup && useradd -m -g flaskgroup -s /bin/bash flask
 ---> Using cache
 ---> e2c30915fcf5
Step 4/10 : RUN mkdir -p /home/flask/app/web
 ---> Using cache
 ---> 8f44dada5953
Step 5/10 : WORKDIR /home/flask/app/web
 ---> Using cache
 ---> 04a895c3fe27
Step 6/10 : COPY requirements.txt /home/flask/app/web
 ---> Using cache
 ---> 13ab37e789f8
Step 7/10 : RUN pip install --no-cache-dir -r requirements.txt
 ---> Running in 61475950cd73
Collecting alembic==0.8.8 (from -r requirements.txt (line 1))
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f1e979262b0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/alembic/

选择一个答案标记问题已解决。请参阅在问题标题中添加“SOLVED”是否可以?以及相关的重复链接。 - Charles Duffy
1个回答

1
解决方案是在云提供商中添加一个UDP出站规则。添加此规则后,预先安装的要求已经完成。
Egress  IPv4    UDP     1 - 65535   0.0.0.0/0 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接