Ubuntu 16.04 :在 dockerfile 中运行"apt-get update "命令时出现错误"Could not connect to archive.ubuntu.com:80 (9



我将对我的问题进行如下处理:

  1. 我想为Hyperledger Indy-sdk构建一个docker镜像
  2. 在构建docker镜像时,它使用docker compose命令来构建两个镜像并将其组合,即indy池镜像和入门镜像。我的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.logn
logfile_maxbytes = 50MBn
logfile_backups=10n
logLevel = errorn
pidfile = /tmp/supervisord.pidn
nodaemon = truen
minfds = 1024n
minprocs = 200n
umask = 022n
user = indyn
identifier = supervisorn
directory = /tmpn
nocleanup = truen
childlogdir = /tmpn
strip_ansi = falsen
n
[program:node1]n
command=start_indy_node Node1 0.0.0.0 9701 0.0.0.0 9702n
directory=/home/indyn
stdout_logfile=/tmp/node1.logn
stderr_logfile=/tmp/node1.logn
n
[program:node2]n
command=start_indy_node Node2 0.0.0.0 9703 0.0.0.0 9704n
directory=/home/indyn
stdout_logfile=/tmp/node2.logn
stderr_logfile=/tmp/node2.logn
n
[program:node3]n
command=start_indy_node Node3 0.0.0.0 9705 0.0.0.0 9706n
directory=/home/indyn
stdout_logfile=/tmp/node3.logn
stderr_logfile=/tmp/node3.logn
n
[program:node4]n
command=start_indy_node Node4 0.0.0.0 9707 0.0.0.0 9708n
directory=/home/indyn
stdout_logfile=/tmp/node4.logn
stderr_logfile=/tmp/node4.logn"
>> /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池镜像都将成功创建,如图所示Ubuntu 16.04和Indy池成功截图

  2. 在此之后,当启动时。docker文件开始运行。获取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. 当在getting-started.dokerfile中执行RUN apt-get-update-y时,整个问题就开始了
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构建和Docker撰写的新手,我坚信这与图像构建过程有关。如果你们中的任何人遇到类似的问题并解决了它,请向我提供解决上述问题的建议。

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

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

可能是代理问题
您可以将docker代理配置设置为~/.docker/config.json
在docker文档中对此进行了解释。

相关内容

  • 没有找到相关文章

最新更新