skip to Main Content

Environment:

Host OS: Mac OS Catalina
Docker Version: Docker version 19.03.8, build afacb8b

Problem:

From inside docker, I have ensured I can ping 8.8.8.8 and also resolve hostnames. But I dont understand why I am seeing ***

unexpected size error

when I run apt update.

From bash terminal, I run the following commands:

docker run -it ubuntu:18.04 bash

root@83c668ee64d0:/# apt update
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://security.debian.org/debian-security buster/updates/main amd64 Packages [201 kB]
Get:3 http://deb.debian.org/debian buster InRelease [121 kB]
Get:4 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7905 kB]
Err:5 http://deb.debian.org/debian buster/main amd64 Packages
  File has unexpected size (13168 != 7905140). Mirror sync in progress? [IP: 151.101.96.204 80]
  Hashes of expected file:
   - Filesize:7905140 [weak]
   - SHA256:1b42c3159a573be2bea3b55e2f55f2236f6c0ca23beac23205d2688b892b3052
   - MD5Sum:9f4af9cc7e89f9ec9607738718505126 [weak]
  Release file created at: Sat, 09 May 2020 09:51:02 +0000
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]
Err:6 http://deb.debian.org/debian buster-updates/main amd64 Packages
  File has unexpected size (13184 != 7380). Mirror sync in progress? [IP: 151.101.96.204 80]
  Hashes of expected file:
   - Filesize:7380 [weak]
   - SHA256:6af9ea081b6a3da33cfaf76a81978517f65d38e45230089a5612e56f2b6b789d
  Release file created at: Wed, 03 Jun 2020 20:19:15 +0000
Fetched 438 kB in 3s (156 kB/s)
Reading package lists... Done
E: Failed to fetch http://deb.debian.org/debian/dists/buster/main/binary-amd64/by-hash/SHA256/1b42c3159a573be2bea3b55e2f55f2236f6c0ca23beac23205d2688b892b3052  File has unexpected size (13168 != 7905140). Mirror sync in progress? [IP: 151.101.96.204 80]
   Hashes of expected file:
    - Filesize:7905140 [weak]
    - SHA256:1b42c3159a573be2bea3b55e2f55f2236f6c0ca23beac23205d2688b892b3052
    - MD5Sum:9f4af9cc7e89f9ec9607738718505126 [weak]
   Release file created at: Sat, 09 May 2020 09:51:02 +0000
E: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/main/binary-amd64/by-hash/SHA256/6af9ea081b6a3da33cfaf76a81978517f65d38e45230089a5612e56f2b6b789d  File has unexpected size (13184 != 7380). Mirror sync in progress? [IP: 151.101.96.204 80]
   Hashes of expected file:
    - Filesize:7380 [weak]
    - SHA256:6af9ea081b6a3da33cfaf76a81978517f65d38e45230089a5612e56f2b6b789d
   Release file created at: Wed, 03 Jun 2020 20:19:15 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.

From inside docker, I have ensured I can ping 8.8.8.8 and also resolve hostnames. But I dont understand why I am seeing unexpected size error

2

Answers


  1. Chosen as BEST ANSWER

    I did the following:

    curl http://deb.debian.org/debian/dists/buster/main/binary-amd64/by-hash/SHA256/1b42c3159a573be2bea3b55e2f55f2236f6c0ca23beac23205d2688b892b3052
    

    and found

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <!--    Applications (such as Dictionary.app) can recognise that a
                    webpage has been restricted by looking for the following comment:   -->
    
            <!-- com.apple.parentalcontrols.webcontentfilter.accessrestricted -->
    
            <title>Access Restricted</title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
            <script type="text/javascript">
    
    <!--
    

    This made sense, my iPad had content restriction and it had synchronised with my iMac and blocked the traffic. To fix go to System preferences -> Screen time -> Content and Privacy -> Turn off content and privacy restriction


  2. This problem occure while using Ubuntu 20.x version.

    Reference of this answer is this link thankful to them.

    Method 2 – Switch back to original mirror
    Before modifying the source lists, it is highly recommended to backup them first:

    $ sudo mv /etc/apt/sources.list{,.backup}
    
    $ sudo mv /etc/apt/sources.list.d{,.backup}
    

    Ubuntu has a sample source lists in /usr/share/doc/apt/examples/sources.list file. Let us take look at the contents of this file:

    $ cat /usr/share/doc/apt/examples/sources.list
    

    Sample output:

    See sources.list(5) manpage for more information

    Remember that CD-ROMs, DVDs and such are managed through the apt-cdrom tool.

    deb http://us.archive.ubuntu.com/ubuntu focal main restricted
    deb-src http://us.archive.ubuntu.com/ubuntu focal main restricted

    deb http://security.ubuntu.com/ubuntu focal-security main restricted
    deb-src http://security.ubuntu.com/ubuntu focal-security main restricted

    deb http://us.archive.ubuntu.com/ubuntu focal-updates main restricted
    deb-src http://us.archive.ubuntu.com/ubuntu focal-updates main restricted
    Now create a new source lists from the sample file like below:

    $ sudo mkdir /etc/apt/sources.list.d
    $ sudo cp /usr/share/doc/apt/examples/sources.list /etc/apt/sources.list
    $ sudo apt update
    

    This will restore all mirrors to main server, usually the mirrors in US.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search