macos - 在 Mac 上的 docker ubuntu 镜像上运行 apt-get update 会导致 "File has unexpected size"

标签 macos docker ubuntu dockerfile apt-get

我正在尝试使用“docker build.”从我的 docker 文件中运行这两行:

FROM ubuntu:latest
RUN apt-get update
这是我运行它时发生的事情(包含错误):
[+] Building 16.0s (6/18)                                                       
 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 923B                                       0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => [internal] load metadata for docker.io/library/ubuntu:latest           5.7s
 => [internal] load build context                                          0.0s
 => => transferring context: 36B                                           0.0s
 => CACHED [ 1/14] FROM docker.io/library/ubuntu:latest@sha256:703218c046  0.0s
 => ERROR [ 2/14] RUN apt-get update                                      10.2s
------                                                                          
 > [ 2/14] RUN apt-get update:                                                  
#5 0.915 Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]                                                                              
#5 1.142 Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]        
#5 1.626 Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
#5 1.648 Get:4 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [664 kB]
#5 1.649 Err:4 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
#5 1.649   File has unexpected size (13216 != 664116). Mirror sync in progress? [IP: 91.189.91.39 80]
#5 1.649   Hashes of expected file:
#5 1.649    - Filesize:664116 [weak]
#5 1.649    - SHA256:bab7d330736bb3f137d539001f4ea9250bc6613772b9a98cfb1241ed81bd2c04
#5 1.649    - SHA1:3ee0d4d62b53860024bdb392707c909b4cc9357c [weak]
#5 1.649    - MD5Sum:87431ac524ec4b25401cea7af4c5b517 [weak]
#5 1.649   Release file created at: Sun, 14 Feb 2021 19:09:36 +0000
#5 1.841 Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
#5 2.445 Get:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [612 kB]
#5 2.446 Err:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
#5 2.446   
#5 2.972 Get:7 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [165 kB]
#5 2.972 Err:7 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages
#5 2.972   
#5 3.040 Get:8 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
#5 3.041 Err:8 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
#5 3.041   File has unexpected size (13194 != 11344505). Mirror sync in progress? [IP: 91.189.88.152 80]
#5 3.041   Hashes of expected file:
#5 3.041    - Filesize:11344505 [weak]
#5 3.041    - SHA256:200acdc3421757fa8f8759c1cedacae2cf8f5821d7810ca59d8a313c5b3ae71e
#5 3.041    - SHA1:28dce64e724849c2296c10a2a3de8334c7829494 [weak]
#5 3.041    - MD5Sum:fc2f03a69a8d61b33e29934cbba9e675 [weak]
#5 3.041   Release file created at: Thu, 23 Apr 2020 17:33:17 +0000
#5 3.212 Get:9 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [13.3 kB]
#5 3.212 Err:9 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages
#5 3.212   
#5 3.907 Get:10 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
#5 3.907 Err:10 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages
#5 3.907   
#5 4.425 Get:11 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
#5 4.425 Err:11 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages
#5 4.425   
#5 6.309 Get:12 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
#5 6.310 Err:12 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
#5 6.310   
#5 7.978 Get:13 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1016 kB]
#5 7.978 Err:13 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
#5 7.978   File has unexpected size (13202 != 1016097). Mirror sync in progress? [IP: 91.189.88.152 80]
#5 7.978   Hashes of expected file:
#5 7.978    - Filesize:1016097 [weak]
#5 7.978    - SHA256:6073eef81f57e5a6fc81d37d07bfa59f35994b89e81c79286b79f6527955e84a
#5 7.978    - SHA1:69a5e1831d1cfd408a2c120f4de248ea2d919005 [weak]
#5 7.978    - MD5Sum:5ea17bb583a7b1b4029167bdc5b3c6a8 [weak]
#5 7.978   Release file created at: Sun, 14 Feb 2021 19:09:51 +0000
#5 9.531 Get:14 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [924 kB]
#5 9.652 Get:15 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [21.1 kB]
#5 9.961 Get:16 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [198 kB]
#5 10.10 Get:17 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [4301 B]
#5 10.13 Fetched 1736 kB in 10s (180 kB/s)
#5 10.13 Reading package lists...
#5 10.15 E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/universe/binary-amd64/by-hash/SHA256/bab7d330736bb3f137d539001f4ea9250bc6613772b9a98cfb1241ed81bd2c04  File has unexpected size (13216 != 664116). Mirror sync in progress? [IP: 91.189.91.39 80]
#5 10.15    Hashes of expected file:
#5 10.15     - Filesize:664116 [weak]
#5 10.15     - SHA256:bab7d330736bb3f137d539001f4ea9250bc6613772b9a98cfb1241ed81bd2c04
#5 10.15     - SHA1:3ee0d4d62b53860024bdb392707c909b4cc9357c [weak]
#5 10.15     - MD5Sum:87431ac524ec4b25401cea7af4c5b517 [weak]
#5 10.15    Release file created at: Sun, 14 Feb 2021 19:09:36 +0000
#5 10.16 E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/main/binary-amd64/by-hash/SHA256/2d506247d2b3080e98624bbec9dfb69d88753039c20b4cbfcae9d53d231c2f2a  
#5 10.16 E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/restricted/binary-amd64/by-hash/SHA256/4e3f319b6b7287529ff17b84b56b8be710fc6133319eba09e609b8ddef49e954  
#5 10.16 E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/multiverse/binary-amd64/by-hash/SHA256/623a09d316fd7bc308280205394c995ba4a1281d77e7d920ee2bc3d0db730c91  
#5 10.16 E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/universe/binary-amd64/by-hash/SHA256/200acdc3421757fa8f8759c1cedacae2cf8f5821d7810ca59d8a313c5b3ae71e  File has unexpected size (13194 != 11344505). Mirror sync in progress? [IP: 91.189.88.152 80]
#5 10.16    Hashes of expected file:
#5 10.16     - Filesize:11344505 [weak]
#5 10.16     - SHA256:200acdc3421757fa8f8759c1cedacae2cf8f5821d7810ca59d8a313c5b3ae71e
#5 10.16     - SHA1:28dce64e724849c2296c10a2a3de8334c7829494 [weak]
#5 10.16     - MD5Sum:fc2f03a69a8d61b33e29934cbba9e675 [weak]
#5 10.16    Release file created at: Thu, 23 Apr 2020 17:33:17 +0000
#5 10.16 E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/multiverse/binary-amd64/by-hash/SHA256/cbe561be81039e8d89187f790d03ead3debbf26b6cbdde29ae8c5137a273dd5c  
#5 10.16 E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/restricted/binary-amd64/by-hash/SHA256/f641509ad1e4ab977debf3d852d1a7e47a02e9d941867f7b277d95cf37d64d49  
#5 10.16 E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/main/binary-amd64/by-hash/SHA256/f25bb719a900d962a4df25cbb20f0a54a23d9f16c3fcdc4f4872ead131f5a604  
#5 10.16 E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/main/binary-amd64/by-hash/SHA256/6073eef81f57e5a6fc81d37d07bfa59f35994b89e81c79286b79f6527955e84a  File has unexpected size (13202 != 1016097). Mirror sync in progress? [IP: 91.189.88.152 80]
#5 10.16    Hashes of expected file:
#5 10.16     - Filesize:1016097 [weak]
#5 10.16     - SHA256:6073eef81f57e5a6fc81d37d07bfa59f35994b89e81c79286b79f6527955e84a
#5 10.16     - SHA1:69a5e1831d1cfd408a2c120f4de248ea2d919005 [weak]
#5 10.16     - MD5Sum:5ea17bb583a7b1b4029167bdc5b3c6a8 [weak]
#5 10.16    Release file created at: Sun, 14 Feb 2021 19:09:51 +0000
#5 10.16 E: Some index files failed to download. They have been ignored, or old ones used instead.
------
executor failed running [/bin/sh -c apt-get update]: exit code: 100
我从我的 MacBook Pro macOS Big Sur 11.1 运行它
我尝试在 Linux 虚拟机上运行 apt-get update 并且一个接一个地得到相同类型的错误。此外,我在同一行中说“文件具有意外大小”,我也不确定它的来源。
注意:这适用于 Windows 机器,但不适用于我的 Mac。
任何帮助表示赞赏!

最佳答案

我遇到了同样的问题,原因是我在我的 iPhone 上设置了内容限制,这些限制会自动同步到我的 Mac。
关闭限制后,一切正常。
转到系统偏好设置>屏幕时间>关闭内容和隐私限制

关于macos - 在 Mac 上的 docker ubuntu 镜像上运行 apt-get update 会导致 "File has unexpected size",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66200219/

相关文章:

macos - Wunderlist 如何在窗口标题栏中创建搜索控件?

stdlib cdefs.h 中的 C++ 错误?

bash - 如何在 Mac 上通过管道进出 dos2unix

jenkins - 在 jenkins docker 容器内执行 docker host 命令

ubuntu - 安装 scrapy 0.22 时出错(在 Ubuntu 12.04 上): 'gcc' failed with exit status 1

android - 在 Android Studio for Google Maps 中获取 SHA1 指纹证书

postgresql - Laravel Docker 无法执行 PostgreSQL pg_restore

amazon-web-services - 在无服务器的AWS Lambda上运行dockerized函数

ubuntu - 启动 VSCode 后无法使用终端

ubuntu - Parallels下的时间同步Ubuntu服务器