0

我将把我的问题如下:

  1. 我想为 Hyperledger Indy-sdk 构建一个 docker 映像
  2. 在构建 docker 镜像时,它使用 docker-compose 命令构建两个镜像并将它们组合起来,即 indy-pool 镜像和入门镜像。我的 docker-compose.yml 文件如下所示
version: '2'
services:
  indy_pool:
    build:
      context: ../../ci/
      dockerfile: indy-pool.dockerfile
      args:
        pool_ip: '10.0.0.2'
    image: indy_pool
    container_name: indy_pool
    working_dir: /home/indy
    ports:
      - "9701:9701"
      - "9702:9702"
      - "9703:9703"
      - "9704:9704"
      - "9705:9705"
      - "9706:9706"
      - "9707:9707"
      - "9708:9708"
    networks:
      pool_network:
        ipv4_address: 10.0.0.2
    volumes:
       - sandbox:/var/lib/indy/sandbox/
  jupyter:
    build:
      context: .
      dockerfile: getting-started.dockerfile
    command: jupyter notebook --ip=0.0.0.0
    image: getting-started
    container_name: getting_started
    working_dir: /home/indy
    volumes:
       - ./getting-started.ipynb:/home/indy/getting-started.ipynb
       - sandbox:/home/indy/sandbox
    ports:
      - "8888:8888"
    networks:
      - pool_network
    links:
      - indy_pool
networks:
  pool_network:
    driver: bridge
    ipam:
      driver: default
      config:
        -
          subnet: 10.0.0.0/24
volumes:
     sandbox:
  1. 上面的 docker-compose 会启动 indy-pool.dockerfile 运行。indy-pool.dockerfile的内容如下图
FROM ubuntu:16.04

ARG uid=1000

# Install environment 
RUN apt-get update -y && apt-get install -y \
    git \
    wget \
    python3.5 \
    python3-pip \
    python-setuptools \
    python3-nacl \
    apt-transport-https \
    ca-certificates \
    supervisor

RUN pip3 install -U \
    pip==9.0.3 \
    setuptools

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 || \
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CE7709D068DB5E88
ARG indy_stream=master
RUN echo "deb https://repo.sovrin.org/deb xenial $indy_stream" >> /etc/apt/sources.list

RUN useradd -ms /bin/bash -u $uid indy

ARG indy_plenum_ver=1.12.1~dev989
ARG indy_node_ver=1.12.1~dev1172
ARG python3_indy_crypto_ver=0.4.5
ARG indy_crypto_ver=0.4.5
ARG python3_pyzmq_ver=18.1.0
ARG python3_orderedset_ver=2.0
ARG python3_psutil_ver=5.4.3
ARG python3_pympler_ver=0.5

RUN apt-get update -y && apt-get install -y \
        python3-pyzmq=${python3_pyzmq_ver} \
        indy-plenum=${indy_plenum_ver} \
        indy-node=${indy_node_ver} \
        python3-indy-crypto=${python3_indy_crypto_ver} \
        libindy-crypto=${indy_crypto_ver} \
        python3-orderedset=${python3_orderedset_ver} \
        python3-psutil=${python3_psutil_ver} \
        python3-pympler=${python3_pympler_ver} \
        vim

RUN echo "[supervisord]\n\
logfile = /tmp/supervisord.log\n\
logfile_maxbytes = 50MB\n\
logfile_backups=10\n\
logLevel = error\n\
pidfile = /tmp/supervisord.pid\n\
nodaemon = true\n\
minfds = 1024\n\
minprocs = 200\n\
umask = 022\n\
user = indy\n\
identifier = supervisor\n\
directory = /tmp\n\
nocleanup = true\n\
childlogdir = /tmp\n\
strip_ansi = false\n\
\n\
[program:node1]\n\
command=start_indy_node Node1 0.0.0.0 9701 0.0.0.0 9702\n\
directory=/home/indy\n\
stdout_logfile=/tmp/node1.log\n\
stderr_logfile=/tmp/node1.log\n\
\n\
[program:node2]\n\
command=start_indy_node Node2 0.0.0.0 9703 0.0.0.0 9704\n\
directory=/home/indy\n\
stdout_logfile=/tmp/node2.log\n\
stderr_logfile=/tmp/node2.log\n\
\n\
[program:node3]\n\
command=start_indy_node Node3 0.0.0.0 9705 0.0.0.0 9706\n\
directory=/home/indy\n\
stdout_logfile=/tmp/node3.log\n\
stderr_logfile=/tmp/node3.log\n\
\n\
[program:node4]\n\
command=start_indy_node Node4 0.0.0.0 9707 0.0.0.0 9708\n\
directory=/home/indy\n\
stdout_logfile=/tmp/node4.log\n\
stderr_logfile=/tmp/node4.log\n"\
>> /etc/supervisord.conf

USER indy

RUN awk '{if (index($1, "NETWORK_NAME") != 0) {print("NETWORK_NAME = \"sandbox\"")} else print($0)}' /etc/indy/indy_config.py> /tmp/indy_config.py
RUN mv /tmp/indy_config.py /etc/indy/indy_config.py

ARG pool_ip=127.0.0.1

RUN generate_indy_pool_transactions --nodes 4 --clients 5 --nodeNum 1 2 3 4 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip"

EXPOSE 9701 9702 9703 9704 9705 9706 9707 9708

CMD ["/usr/bin/supervisord"]
  1. 现在 Ubuntu 16.04 映像和 indy-pool 映像都将成功创建,如图 Ubuntu 16.04 和 Indy-pool Success Screenshot所示

  2. 在此之后,当 getting-started.dockerfile 开始运行时。获取-staretd.dockerfile 看起来像这样

FROM ubuntu:16.04

RUN useradd -ms /bin/bash indy

# Install environment
RUN  apt-get update -y &&   apt-get install -y \
    wget \
    python3.5 \
    python3-pip \
    python-setuptools \
    apt-transport-https \
    ca-certificates \
    software-properties-common

WORKDIR /home/indy

RUN pip3 install -U \
    pip \
    ipython-notebook \
      ipython==7.9 \
    setuptools \
    jupyter \
    python3-indy==1.11.0

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 \
    && add-apt-repository "deb https://repo.sovrin.org/sdk/deb xenial stable" \
    && apt-get update \
    && apt-get install -y \
    libindy=1.11.0

USER indy

EXPOSE 8888
  1. 当 RUN apt-get update -y 在 getting-started.dockerfile 中执行时,整个问题就开始了。以下错误行显示给我
Err:6 http://archive.ubuntu.com/ubuntu xenial InRelease
  Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out [IP: 91.189.88.152 80]
Err:7 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.152 80]
Err:8 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.152 80]
Fetched 3168 kB in 4min 0s (13.2 kB/s)
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out [IP: 91.189.88.152 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.152 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.152 80]

注意:我的 docker 引擎和 docker-compose 安装在 Ubuntu 20.04 之上

为了解决这个问题,我访问了互联网上的多个可用资源。我可以说这不是 DNS 查找和 http 代理的问题(因为我不在代理网络中工作)。

由于我是 Docker build 和 docker compose 的新手,我坚信这与图像构建过程有关。如果你们中的任何人遇到类似的问题并解决了它,请向我提供解决上述问题的建议。

4

1 回答 1

1

尝试使用--network=host解决依赖项并能够使用 indy SDK 创建图像的选项进行构建

docker build --network=host -t indy-image .
于 2021-06-16T18:05:25.770 回答