for-mac icon indicating copy to clipboard operation
for-mac copied to clipboard

Docker build failed with Hash Sum mismatch error on MacOS 14 Sonoma (M1 Chip)

Open xinen8721 opened this issue 2 years ago • 21 comments

Description

I am getting consistent docker build Hash Sum mismatcherror under MAC OS 14 Sonoma

Minimum reproducible example:

  1. docker run --rm -it debian:buster-20210927 sh -xc "apt-get clean && apt-get update && apt-get install -y --no-install-recommends librsvg2-bin"
  2. docker run --rm -it debian:buster-20230919 sh -xc "apt-get clean && apt-get update && apt-get install -y --no-install-recommends librsvg2-bin"

Full console output:

+ apt-get clean
+ apt-get update
Get:1 http://deb.debian.org/debian buster InRelease [122 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [34.8 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [56.6 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main arm64 Packages [541 kB]
Get:5 http://deb.debian.org/debian buster/main arm64 Packages [7737 kB]
Get:6 http://deb.debian.org/debian buster-updates/main arm64 Packages [8780 B]
Fetched 8500 kB in 2s (4197 kB/s)
Reading package lists... Done
+ apt-get install -y --no-install-recommends librsvg2-bin
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  adwaita-icon-theme dbus dbus-user-session dconf-gsettings-backend dconf-service dmsetup fontconfig fontconfig-config fonts-dejavu-core glib-networking glib-networking-common glib-networking-services
  gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme libapparmor1 libargon2-1 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3
  libbsd0 libcairo-gobject2 libcairo2 libcolord2 libcroco3 libcryptsetup12 libcups2 libdatrie1 libdbus-1-3 libdconf1 libdevmapper1.02.1 libepoxy0 libexpat1 libfontconfig1 libfreetype6 libfribidi0
  libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libglib2.0-0 libgraphite2-3 libgssapi-krb5-2 libgtk-3-0 libgtk-3-common libharfbuzz0b libicu63 libidn11 libip4tc0 libjbig0 libjpeg62-turbo libjson-c3
  libjson-glib-1.0-0 libjson-glib-1.0-common libk5crypto3 libkeyutils1 libkmod2 libkrb5-3 libkrb5support0 liblcms2-2 libpam-systemd libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpixman-1-0 libpng16-16
  libproxy1v5 libpsl5 librest-0.7-0 librsvg2-2 librsvg2-common libsoup-gnome2.4-1 libsoup2.4-1 libsqlite3-0 libssl1.1 libsystemd0 libthai-data libthai0 libtiff5 libwayland-client0 libwayland-cursor0
  libwayland-egl1 libwebp6 libx11-6 libx11-data libxau6 libxcb-render0 libxcb-shm0 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxml2 libxrandr2
  libxrender1 sensible-utils shared-mime-info systemd systemd-sysv ucf xkb-data
Suggested packages:
  colord cups-common krb5-doc krb5-user gvfs liblcms2-utils systemd-container policykit-1
Recommended packages:
  at-spi2-core libgdk-pixbuf2.0-bin libglib2.0-data xdg-user-dirs libgtk-3-bin krb5-locales publicsuffix libnss-systemd
The following NEW packages will be installed:
  adwaita-icon-theme dbus dbus-user-session dconf-gsettings-backend dconf-service dmsetup fontconfig fontconfig-config fonts-dejavu-core glib-networking glib-networking-common glib-networking-services
  gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme libapparmor1 libargon2-1 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3
  libbsd0 libcairo-gobject2 libcairo2 libcolord2 libcroco3 libcryptsetup12 libcups2 libdatrie1 libdbus-1-3 libdconf1 libdevmapper1.02.1 libepoxy0 libexpat1 libfontconfig1 libfreetype6 libfribidi0
  libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libglib2.0-0 libgraphite2-3 libgssapi-krb5-2 libgtk-3-0 libgtk-3-common libharfbuzz0b libicu63 libidn11 libip4tc0 libjbig0 libjpeg62-turbo libjson-c3
  libjson-glib-1.0-0 libjson-glib-1.0-common libk5crypto3 libkeyutils1 libkmod2 libkrb5-3 libkrb5support0 liblcms2-2 libpam-systemd libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpixman-1-0 libpng16-16
  libproxy1v5 libpsl5 librest-0.7-0 librsvg2-2 librsvg2-bin librsvg2-common libsoup-gnome2.4-1 libsoup2.4-1 libsqlite3-0 libssl1.1 libthai-data libthai0 libtiff5 libwayland-client0 libwayland-cursor0
  libwayland-egl1 libwebp6 libx11-6 libx11-data libxau6 libxcb-render0 libxcb-shm0 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxml2 libxrandr2
  libxrender1 sensible-utils shared-mime-info systemd systemd-sysv ucf xkb-data
The following packages will be upgraded:
  libsystemd0
1 upgraded, 109 newly installed, 0 to remove and 21 not upgraded.
Need to get 49.8 MB of archives.
After this operation, 177 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main arm64 libapparmor1 arm64 2.13.2-10 [93.8 kB]
Get:2 http://security.debian.org/debian-security buster/updates/main arm64 libsystemd0 arm64 241-7~deb10u10 [313 kB]
Get:3 http://deb.debian.org/debian buster/main arm64 libargon2-1 arm64 0~20171227-0.2 [18.9 kB]
Get:4 http://deb.debian.org/debian buster/main arm64 dmsetup arm64 2:1.02.155-3 [83.9 kB]
Get:5 http://deb.debian.org/debian buster/main arm64 libdevmapper1.02.1 arm64 2:1.02.155-3 [124 kB]
Get:6 http://security.debian.org/debian-security buster/updates/main arm64 libssl1.1 arm64 1.1.1n-0+deb10u6 [1395 kB]
Get:7 http://deb.debian.org/debian buster/main arm64 libjson-c3 arm64 0.12.1+ds-2+deb10u1 [26.8 kB]
Get:8 http://deb.debian.org/debian buster/main arm64 libcryptsetup12 arm64 2:2.1.0-5+deb10u2 [181 kB]
Err:8 http://deb.debian.org/debian buster/main arm64 libcryptsetup12 arm64 2:2.1.0-5+deb10u2
  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:4a3073bf53c582881992059f931737aaad2057baa5ed84afb843117dc4751d46
   - MD5Sum:fcc60a575d72a446319a655c85049ad4 [weak]
   - Filesize:181396 [weak]
  Hashes of received file:
   - SHA256:9b749c0018ac59849b5ce3a4a700d5cc0fab3f0e81563afb80245d53ec1754b7
   - MD5Sum:db64568e78fa30388c832389946050bd [weak]
   - Filesize:181396 [weak]
  Last modification reported: Sun, 01 Sep 2019 03:14:21 +0000
Get:9 http://security.debian.org/debian-security buster/updates/main arm64 systemd arm64 241-7~deb10u10 [3262 kB]
Get:10 http://security.debian.org/debian-security buster/updates/main arm64 systemd-sysv arm64 241-7~deb10u10 [100 kB]
Get:11 http://security.debian.org/debian-security buster/updates/main arm64 libdbus-1-3 arm64 1.12.24-0+deb10u1 [209 kB]
Get:12 http://security.debian.org/debian-security buster/updates/main arm64 libexpat1 arm64 2.2.6-2+deb10u6 [87.5 kB]
Get:13 http://security.debian.org/debian-security buster/updates/main arm64 dbus arm64 1.12.24-0+deb10u1 [231 kB]
Err:13 http://security.debian.org/debian-security buster/updates/main arm64 dbus arm64 1.12.24-0+deb10u1
  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:777360af8fc7e0f86d33f021b25e137fa30930e133ecaad118c5a7daecdd28f8
   - MD5Sum:e4a2c5855d620a0eb54a33c7f8d86eb0 [weak]
   - Filesize:230560 [weak]
  Hashes of received file:
   - SHA256:995abb25e4a461b4e6a75d62476d97a9ba56677e6c4e534a00cbeb10de25191b
   - MD5Sum:81525087802c958a2322f235f02ad46a [weak]
   - Filesize:230560 [weak]
  Last modification reported: Mon, 10 Oct 2022 11:57:09 +0000
Err:14 http://security.debian.org/debian-security buster/updates/main arm64 libkrb5support0 arm64 1.17-3+deb10u5
  Bad header line Bad header data [IP: 151.101.130.132 80]
Get:15 http://security.debian.org/debian-security buster/updates/main arm64 libk5crypto3 arm64 1.17-3+deb10u5 [123 kB]
Get:16 http://security.debian.org/debian-security buster/updates/main arm64 libkrb5-3 arm64 1.17-3+deb10u5 [351 kB]
Get:17 http://security.debian.org/debian-security buster/updates/main arm64 libgssapi-krb5-2 arm64 1.17-3+deb10u5 [150 kB]
Get:18 http://security.debian.org/debian-security buster/updates/main arm64 libpam-systemd arm64 241-7~deb10u10 [200 kB]
Get:19 http://security.debian.org/debian-security buster/updates/main arm64 libsqlite3-0 arm64 3.27.2-3+deb10u2 [603 kB]
Get:20 http://security.debian.org/debian-security buster/updates/main arm64 libxml2 arm64 2.9.4+dfsg1-7+deb10u6 [625 kB]
Get:21 http://security.debian.org/debian-security buster/updates/main arm64 libglib2.0-0 arm64 2.58.3-2+deb10u5 [1188 kB]
Get:22 http://security.debian.org/debian-security buster/updates/main arm64 libwebp6 arm64 0.6.1-2+deb10u3 [246 kB]
Get:23 http://security.debian.org/debian-security buster/updates/main arm64 libtiff5 arm64 4.1.0+git191117-2~deb10u8 [261 kB]
Get:24 http://security.debian.org/debian-security buster/updates/main arm64 libx11-data all 2:1.6.7-1+deb10u4 [299 kB]
Get:25 http://security.debian.org/debian-security buster/updates/main arm64 libx11-6 arm64 2:1.6.7-1+deb10u4 [735 kB]
Get:26 http://security.debian.org/debian-security buster/updates/main arm64 libpixman-1-0 arm64 0.36.0-1+deb10u1 [134 kB]
Get:27 http://security.debian.org/debian-security buster/updates/main arm64 dbus-user-session arm64 1.12.24-0+deb10u1 [97.9 kB]
Get:28 http://security.debian.org/debian-security buster/updates/main arm64 libavahi-common-data arm64 0.7-4+deb10u3 [122 kB]
Get:29 http://security.debian.org/debian-security buster/updates/main arm64 libavahi-common3 arm64 0.7-4+deb10u3 [53.7 kB]
Get:30 http://security.debian.org/debian-security buster/updates/main arm64 libavahi-client3 arm64 0.7-4+deb10u3 [57.3 kB]
Get:31 http://security.debian.org/debian-security buster/updates/main arm64 libcups2 arm64 2.2.10-6+deb10u9 [311 kB]
23% [Waiting for headers]

Reproduce

docker run --rm -it debian:buster-20210927 sh -xc "apt-get clean && apt-get update && apt-get install -y --no-install-recommends librsvg2-bin"

I get Hash Sum errors like

Err:86 http://deb.debian.org/debian buster/main arm64 libcairo-gobject2 arm64 1.16.0-4+deb10u1
  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:1d0a6e2143932dabecdbf93b917300f29ae0df323e6e489f3355f29e8049d704
   - MD5Sum:9779cec387a22978f0e753b53bcaa0d2 [weak]
   - Filesize:124140 [weak]
  Hashes of received file:
   - SHA256:8b481460db1f00277cbe8f065538ba1eb2ec5c514f54899192e2f3b288686f16
   - MD5Sum:04147d21d239cb9d3e1d0994075c0d68 [weak]
   - Filesize:124140 [weak]
  Last modification reported: Sun, 31 Jan 2021 02:58:48 +0000

Expected behavior

The docker build/run successfully.

docker version

docker version
Client:
 Cloud integration: v1.0.35+desktop.5
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:28:49 2023
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.24.0 (122432)
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:31:36 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

docker info
Client:
 Version:    24.0.6
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2-desktop.5
    Path:     /Users/nxi/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.22.0-desktop.2
    Path:     /Users/nxi/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/nxi/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.20
    Path:     /Users/nxi/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.8
    Path:     /Users/nxi/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/nxi/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/nxi/.docker/cli-plugins/docker-scan
  scout: Docker Scout (Docker Inc.)
    Version:  v1.0.7
    Path:     /Users/nxi/.docker/cli-plugins/docker-scout

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 2
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.4.16-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 11
 Total Memory: 7.667GiB
 Name: docker-desktop
 ID: 6a52f523-7483-4e58-a700-56358e47ac43
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

Diagnostics ID

BBE2C013-9288-46FC-9550-D729D9B6ADD8/20231009184505

Additional Info

No

xinen8721 avatar Oct 09 '23 19:10 xinen8721

i see the same issue on all macs m1/m2 after upgrade to docker 4.24

Client:
 Cloud integration: v1.0.35+desktop.5
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:28:49 2023
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.24.0 (122432)
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:31:36 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0```

p4cket avatar Oct 10 '23 17:10 p4cket

@p4cket I was fortunate enough to find a workaround You can refer to the links below

  1. https://serverfault.com/a/743015
  2. https://gist.github.com/trastle/5722089?permalink_comment_id=3714332

Basically the fix to disable the proxy cache in Dockerfile by adding another layer.

RUN echo 'Acquire::http::Pipeline-Depth 0;\nAcquire::http::No-Cache true;\nAcquire::BrokenProxy true;\n' > /etc/apt/apt.conf.d/99fixbadproxy

For me, this issue happened with previous docker versions such 4.22 and 4.23 after I upgraded to Sonoma MacOS 14.0

xinen8721 avatar Oct 10 '23 18:10 xinen8721

@xinen8721 thanks, will test it out. I think on my side its also was related with MacOs Upgrade, not Docker.

Edit. Your solution solved the issue - thank you!!!!! Edit2. Its not solved issue, now it can finish but 50% its still failing

p4cket avatar Oct 10 '23 18:10 p4cket

Any fixes on this yet? I'm getting the same issue. The fix above did not work.

izaguirrejoe avatar Oct 17 '23 23:10 izaguirrejoe

Same issue, for the last two weeks, driving me mad. This thread is the first confirmation that I'm not completely crazy.

polgfred avatar Oct 25 '23 03:10 polgfred

My current "workaround" is using a remote builder. Not good 😔. So Docker on Mac is just...broken?

izaguirrejoe avatar Oct 25 '23 03:10 izaguirrejoe

Any fixes on this yet? I'm getting the same issue. The fix above did not work.

Hmm, I'm having this exact issue and it's working for me. But you have to be able to add that file to your docker base image in /etc/apt/apt.conf.d, above where any apt-get commands might be run. So it's not a simple patch. :/

polgfred avatar Oct 25 '23 04:10 polgfred

I'm experiencing the same issue.

What I don't understand is why I encounter this problem on the 2020 MacBook Pro M1 but not on the 2021 MacBook Pro M1 Max. Both machines have the same Docker version and the same OS version.

valimero avatar Oct 25 '23 11:10 valimero

+1

gorkememir avatar Oct 25 '23 14:10 gorkememir

🆙 same issue here. Been unable to find a solution without changing Dockerfile with an extra layer

AmbrosioV avatar Oct 25 '23 19:10 AmbrosioV

Also experiencing this on macOS Sonoma 14.1 with Docker 4.25.0.

joelgarrett avatar Nov 01 '23 15:11 joelgarrett

I found this answer which solved it for me : https://stackoverflow.com/questions/66200219/running-apt-get-update-on-docker-ubuntu-image-on-mac-causes-file-has-unexpected

Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off

But i don't know why ...

KevinLbr avatar Nov 02 '23 09:11 KevinLbr

I found this answer which solved it for me : https://stackoverflow.com/questions/66200219/running-apt-get-update-on-docker-ubuntu-image-on-mac-causes-file-has-unexpected

Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off

But i don't know why ...

Wow, that is... something. I suspect that Content/Privacy restrictions work by doing some fancy proxying waaaay down at the network layer, and it's interacting with package proxies in a weird way. Just, wow. Thanks for linking that over!

polgfred avatar Nov 07 '23 05:11 polgfred

I found this answer which solved it for me : https://stackoverflow.com/questions/66200219/running-apt-get-update-on-docker-ubuntu-image-on-mac-causes-file-has-unexpected

Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off

But i don't know why ...

I had it off always and still have this issue ;(

p4cket avatar Nov 09 '23 13:11 p4cket

Edit: After fully uninstalling Docker Desktop and reinstalling cleanly, the issue appears to be resolved on my machine.

Perhaps there is some kind of bug in the Docker Desktop update process?


I can reproduce the OP's error when running:

docker run --rm -it debian:buster-20210927 sh -xc "apt-get clean && apt-get update && apt-get install -y --no-install-recommends librsvg2-bin"

I get the same Hash Sum mismatch issues.

The problem started for me when I upgraded to Docker Desktop 4.26.0.

Environment

  • macOS 13.6.1
  • x86-64 CPU architecture
  • Docker Desktop 4.26.0
$ docker version
Client:
 Cloud integration: v1.0.35+desktop.5
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.20.10
 Git commit:        afdd53b
 Built:             Thu Oct 26 09:04:20 2023
 OS/Arch:           darwin/amd64
 Context:           desktop-linux

Server: Docker Desktop 4.26.0 (130397)
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.10
  Git commit:       311b9ff
  Built:            Thu Oct 26 09:08:02 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.25
  GitCommit:        d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
 runc:
  Version:          1.1.10
  GitCommit:        v1.1.10-0-g18a0cb0
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

johnthagen avatar Dec 07 '23 14:12 johnthagen

Same problem guys. Cannot install wkhtmltopdf in my docker images

RoTorEx avatar Dec 19 '23 17:12 RoTorEx

I found this answer which solved it for me : https://stackoverflow.com/questions/66200219/running-apt-get-update-on-docker-ubuntu-image-on-mac-causes-file-has-unexpected

Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off

But i don't know why ...

Oh my God... It works with my environmental MacOS 14.1, Docker Desktop 4.26.1 . Thanks a lot!

RoTorEx avatar Dec 19 '23 18:12 RoTorEx

Ok i found a solution, https://support.apple.com/en-ca/guide/deployment/dep1129ff8d2/web problem appears only when this is enabled and forces the system to do content filtering. We disabled in in our MDM and this fixed the issue.

p4cket avatar Dec 21 '23 20:12 p4cket

Just ran into this an M1 Mac on Sonoma 14.1 (23B74) with the node:18.19-bookworm image after updating Docker to v4.27.1. Currently in the process of clearing and resetting Docker and updating to Sonoma 14.3.

The content filtering wasn't on for me and none of the other fixes seemed to work so far.

Client:
 Cloud integration: v1.0.35+desktop.10
 Version:           25.0.2
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        29cf629
 Built:             Thu Feb  1 00:18:45 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.27.1 (136059)
 Engine:
  Version:          25.0.2
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       fce6e0c
  Built:            Thu Feb  1 00:23:21 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Edit: So far neither updating Sonoma to 14.3 nor uninstalling/reinstalling Docker has helped. It seems to be affecting different images too.

Edit 2: What fixed it for me what turning on my VPN. Another fix was connecting to my mobile hot spot. My default connection to my wifi seemed to be causing the issue. Reading over fixes for the internet, apparently there might be a caching issue with the Ubuntu mirrors used by the apt source list. This is a bug that was linked by one of the resources I found: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/972077

Doesn't seem like a Docker issue in my case.

dereekb avatar Feb 12 '24 20:02 dereekb

Removing the content filter in apple devices helped me resolve this issue. I have no idea why this is the case though

anukin avatar Aug 13 '24 21:08 anukin

I found this answer which solved it for me : https://stackoverflow.com/questions/66200219/running-apt-get-update-on-docker-ubuntu-image-on-mac-causes-file-has-unexpected

Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off

But i don't know why ...

That works...

NikoKS avatar Sep 04 '24 09:09 NikoKS

Same. Disabled content and privacy on mac. It's working now

denisorehovsky avatar Oct 14 '24 07:10 denisorehovsky

I found this answer which solved it for me : https://stackoverflow.com/questions/66200219/running-apt-get-update-on-docker-ubuntu-image-on-mac-causes-file-has-unexpected Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off But i don't know why ...

I had it off always and still have this issue ;(

Thank you

vasi26ro avatar Oct 23 '24 08:10 vasi26ro

Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off

and a reboot should be in the Install Instructions.

ghost avatar Nov 20 '24 10:11 ghost

disabled content and privacy, M3 chip Sonoma 14.6.1. thanks for the fix

samarqureshii avatar Nov 20 '24 21:11 samarqureshii

@p4cket I was fortunate enough to find a workaround You can refer to the links below

  1. https://serverfault.com/a/743015
  2. https://gist.github.com/trastle/5722089?permalink_comment_id=3714332

Basically the fix to disable the proxy cache in Dockerfile by adding another layer.

RUN echo 'Acquire::http::Pipeline-Depth 0;\nAcquire::http::No-Cache true;\nAcquire::BrokenProxy true;\n' > /etc/apt/apt.conf.d/99fixbadproxy

For me, this issue happened with previous docker versions such 4.22 and 4.23 after I upgraded to Sonoma MacOS 14.0

This also fixed it for me, I already had Content & Privacy Restrictions off. Using an apple chip device with MDM installed

0xMiguel avatar Dec 12 '24 03:12 0xMiguel

I found this answer which solved it for me : https://stackoverflow.com/questions/66200219/running-apt-get-update-on-docker-ubuntu-image-on-mac-causes-file-has-unexpected

Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off

But i don't know why ...

I had this issue on Apple M2 Pro. This suggestion helped me resolve the issue. Thanks

onkarjanwa avatar Jan 27 '25 07:01 onkarjanwa

Was still facing this with both OrbStack and Docker Desktop on MacOS 15.2.

Confirming that the following worked:

1 . System Preferences > Screen Time > Turn Content & Privacy Restrictions off 2. Add RUN echo 'Acquire::http::Pipeline-Depth 0;\nAcquire::http::No-Cache true;\nAcquire::BrokenProxy true;\n' > /etc/apt/apt.conf.d/99fixbadproxy 3 Purged all relevant caches for the build and ran the build again. 4. Still not a 100% success rate, but does the job to at least get the build through after repeating the build command again while re-using the layer caches.

ms337 avatar May 25 '25 21:05 ms337

I found this answer which solved it for me : https://stackoverflow.com/questions/66200219/running-apt-get-update-on-docker-ubuntu-image-on-mac-causes-file-has-unexpected Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off But i don't know why ...

Oh my God... It works with my environmental MacOS 14.1, Docker Desktop 4.26.1 . Thanks a lot!

This also worked for me. Thank you

clerkr avatar May 30 '25 04:05 clerkr

I found this answer which solved it for me : https://stackoverflow.com/questions/66200219/running-apt-get-update-on-docker-ubuntu-image-on-mac-causes-file-has-unexpected

Go to System Preferences > Screen Time > Turn Content & Privacy Restrictions off

But i don't know why ...

Worked for me as well, thank you!

nathandebalthasar avatar Sep 03 '25 10:09 nathandebalthasar