Vir Gandhi
Vir Gandhi

Reputation: 68

Docker Packages: Hash Sum Mismatch

I am getting the following error while doing apt-get update (Ubuntu 14.04)

Hit http://archive.ubuntu.com trusty/main amd64 Packages                       
Hit http://archive.ubuntu.com trusty/restricted amd64 Packages                 
Hit http://archive.ubuntu.com trusty/universe amd64 Packages                   
Fetched 3156 kB in 15s (201 kB/s)                                              
W: **Failed to fetch https://apt.dockerproject.org/repo/dists/ubuntu-trusty/main/binary-amd64/Packages  Hash Sum mismatch**

E: Some index files failed to download. They have been ignored, or old ones used instead.

Upvotes: 1

Views: 3802

Answers (4)

Nicolas Marshall
Nicolas Marshall

Reputation: 4456

This issue can also be caused by any proxies running on your host machine. For instance, SOCKS/DNS proxies, VPNs, network filters (e.g. parental controls on macOS actually tamper with network traffic).

The solution for me was to disable any such non-transparent proxies.

Upvotes: 0

Srikanth
Srikanth

Reputation: 2114

The chosen solution didn't work for me. And I noticed that this isn't always the case - that is, if I wait a day or two, I don't get the error. I suspect it has more to do with the ubuntu repositories than the version of docker we use (as explained by Robie).

My solution is to use one of the official mirrors instead of the default ubuntu repo. Replace xenial with your ubuntu version. You might need an extra deb-src line for all or none of the lines depending on where you are getting the mismatch. I noticed that the mirrors are slower compared to the default.

RUN rm -rf /etc/apt/sources.list
RUN echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted universe multiverse" >> /etc/apt/sources.list
RUN echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted universe multiverse" >> /etc/apt/sources.list
RUN echo "deb-src mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted universe multiverse" >> /etc/apt/sources.list
RUN echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main restricted universe multiverse" >> /etc/apt/sources.list
RUN echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted universe multiverse" >> /etc/apt/sources.list

Upvotes: 0

enderland
enderland

Reputation: 14185

This is a known bug in docker currently, see here.

There are a few workarounds listed in that thread, depending on where you are hitting this problem (travis CI is different than locally).

Upvotes: 1

Feng Yu
Feng Yu

Reputation: 1493

Did you add the gpg key of docker repo?

From the official doc:

$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

Upvotes: 1

Related Questions