简体   繁体   English

在 Mac 上的 docker ubuntu 映像上运行 apt-get update 会导致“文件具有意外大小”

[英]Running apt-get update on docker ubuntu image on Mac causes “File has unexpected size”

I'm trying to run these two lines from my docker file using "docker build. ":我正在尝试使用“docker build.”从我的 docker 文件中运行这两行:

FROM ubuntu:latest
RUN apt-get update

This is what happens when I run it (containing the errors):这是我运行它时发生的事情(包含错误):

[+] 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

I'm running this from my MacBook Pro macOS Big Sur 11.1 I tried running apt-get update on a Linux virtual machine and got the same kind of errors one after another.我从我的 MacBook Pro macOS Big Sur 11.1 上运行这个我尝试在 Linux 虚拟机上运行 apt-get update 并且一个接一个地遇到相同类型的错误。 Also, I had the same line where it says "file has unexpected size" and I'm not sure the source of that either.此外,我在同一行中说“文件具有意外大小”,我也不确定它的来源。

NOTE: This works on a Windows machine, but won't work on my Mac.注意:这适用于 Windows 机器,但不适用于我的 Mac。

Any help appreciated!!!任何帮助表示赞赏!

I had the same issue and the reasons turned out to be that I had content restriction set on my iPhone and these were automatically synced to my Mac.我遇到了同样的问题,原因是我在我的 iPhone 上设置了内容限制,这些限制会自动同步到我的 Mac。

After switching the restrictions off everything worked as it should.关闭限制后,一切正常。

Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off Go 到系统偏好设置 > 屏幕时间 > 关闭内容和隐私限制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM