linux - Ubuntu 16.04 : Error "Could not connect to archive.ubuntu.com:80 (91.189.88.152)" while running "apt-get update " command in a dockerfile

标签 linux docker ubuntu docker-compose hyperledger-indy

我将把我的问题如下:

  • 我想为 Hyperledger Indy-sdk
  • 构建一个 docker 镜像
  • 在构建 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:
    
  • 上面的 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"]
    
  • 现在 Ubuntu 16.04 镜像和 indy-pool 镜像都将成功创建,如图所示
    Ubuntu 16.04 and Indy-pool Success Screenshot
  • 在此之后,当 getting-started.dockerfile 开始运行时。 getting-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
    
  • 当 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 的新手,我坚信这与图像构建过程有关。如果你们中的任何人遇到类似的问题并解决了它,请向我提供解决上述问题的建议。

    最佳答案

    尝试使用选项 --network=host 构建依赖关系得到解决,并且能够使用 indy SDK 创建图像

    docker build --network=host -t indy-image .
    

    关于linux - Ubuntu 16.04 : Error "Could not connect to archive.ubuntu.com:80 (91.189.88.152)" while running "apt-get update " command in a dockerfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67487156/

    相关文章:

    python - 在 Kubuntu 11.04 上更新到 Python 3——我应该/应该卸载以前的版本吗?

    linux - 将进程标准输入和标准输出重定向到 netcat

    linux - 如何通过 hive 表向 hbase 中插入数据?

    linux - 如何准确查看链接到我的程序中的内容?

    docker - 在 CentOS7 中无法启动 docker daemon

    docker - 有人可以解释kubernetes pod资源扩展

    mongodb - 在共享文件夹下运行Mongo的Boot2Docker(在Windows上)(不支持此文件系统)

    c++ - 尝试读取 9 到 13 之间的无符号字符时,ifstream 的行为非常奇怪

    从 stdin 进行子采样的 Linux 命令

    linux - 无需 dyndns 即可从世界各地访问树莓派