簡體   English   中英

使用 ubuntu 構建 docker 映像時 apt-get update 失敗

[英]apt-get update failing when building a docker image with ubuntu

我正在嘗試在 Mac 上使用 ubuntu:latest 構建 docker 映像。 我正在使用 shell 文件來收集設置步驟,但是當容器運行apt-get update時構建停止。

錯誤是:

Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Err:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
  Connection failed [IP: 185.125.190.39 80] 

我的Dockerfile是:

FROM ubuntu
RUN chmod +x set_up.sh
RUN ./set_up.sh 

set_up.sh

#!/bin/sh

#1. Update package manager 
apt-get  update  

對於上下文,如果我使用,我會得到同樣的錯誤

docker run --rm -it ubuntu:latest /bin/bash
root@fca959160783:/# apt-get update
0% [Waiting for headers] [Waiting for headers]
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Err:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
  Connection failed [IP: 185.125.190.39 80]
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease
  Connection failed [IP: 185.125.190.39 80]
Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
  Connection failed [IP: 185.125.190.39 80]
Err:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
  Connection failed [IP: 91.189.91.38 80]
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease  Connection failed [IP: 185.125.190.39 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease  Connection failed [IP: 185.125.190.39 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease  Connection failed [IP: 91.189.91.38 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease  Connection failed [IP: 185.125.190.39 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.

命令掛在0% [Waiting for headers] [Waiting for headers]很長一段時間,然后才產生其余的結果。

我是 docker 新手,但昨天我一直在不同的 WiFi 連接上運行相同的代碼,我沒有遇到任何問題。 我嘗試在示例的 docker docker run版本中將選項--network=host添加到構建命令或我當前的 DNS IP 地址,但我遇到了同樣的問題,我不知道現在該怎么做。 我會很感激你在這個問題上可能有的任何建議。

非常感謝你的幫助!

這可能是架構不匹配。 檢查 docker 架構: docker info | grep Architecture docker info | grep Architecture檢查鏡像架構: docker inspect ubuntu

在不匹配的情況下,您應該重新安裝 docker。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM