103

I am trying to create a docker image from my docker file which has the following content:

FROM ubuntu:14.04.4
RUN echo 'deb http://private-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.4.2.0 HDP main' >> /etc/apt/sources.list.d/HDP.list
RUN echo 'deb http://private-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/ubuntu14 HDP-UTILS main'  >> /etc/apt/sources.list.d/HDP.list
RUN echo 'deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/azurecore/ trusty main' >> /etc/apt/sources.list.d/azure-public-trusty.list
RUN gpg --keyserver pgp.mit.edu --recv-keys B9733A7A07513CAD
RUN gpg -a --export 07513CAD | apt-key add -
RUN gpg --keyserver pgp.mit.edu --recv-keys B02C46DF417A0893
RUN gpg -a --export 417A0893 | apt-key add -
RUN apt-get update

which fails with the following error:

root@sbd-docker:~/ubuntu# docker build -t hdinsight .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM ubuntu:14.04.4
 ---> 8f1bd21bd25c
Step 2 : RUN echo 'deb http://private-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.4.2.0 HDP main' >> /etc/apt/sources.list.d/HDP.list
 ---> Using cache
 ---> bc23070c0b18
Step 3 : RUN echo 'deb http://private-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/ubuntu14 HDP-UTILS main'  >> /etc/apt/sources.list.d/HDP.list
 ---> Using cache
 ---> e45c32975e28
Step 4 : RUN echo 'deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/azurecore/ trusty main' >> /etc/apt/sources.list.d/azure-public-trusty.list
 ---> Using cache
 ---> 1659cdcab06e
Step 5 : RUN gpg --keyserver pgp.mit.edu --recv-keys B9733A7A07513CAD
 ---> Using cache
 ---> ca73b2bfcd21
Step 6 : RUN gpg -a --export 07513CAD | apt-key add -
  ---> Using cache
  ---> 95596ad10bc9
Step 7 : RUN gpg --keyserver pgp.mit.edu --recv-keys B02C46DF417A0893
 ---> Using cache
 ---> f497deeef5b5
Step 8 : RUN gpg -a --export 417A0893 | apt-key add -
 ---> Using cache
 ---> d01dbe7fa02e
Step 9 : RUN apt-get update
 ---> Running in 89d75799982f
E: The method driver /usr/lib/apt/methods/https could not be found.
The command '/bin/sh -c apt-get update' returned a non-zero code: 100
root@sbd-docker:~/ubuntu#

I am running this on Ubuntu 14.04.4.

I tried restarting docker, cleaning up all docker images, installing apt-transport-https, but nothing worked.

I dont know whats wrong here.

questionto42
  • 7,175
  • 4
  • 57
  • 90
roy
  • 6,344
  • 24
  • 92
  • 174
  • 7
    You should consider merging the multiple run commands to minimize the number of layers being created on the backend. – BMitch Jun 24 '16 at 00:55
  • @BMitch what does this mean? Could you elaborate on this a little? Thanks – jjstcool Nov 11 '21 at 15:47
  • 2
    @jjstcool https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#minimize-the-number-of-layers – BMitch Nov 11 '21 at 15:55

10 Answers10

103

Because you have an https sources. Install apt-transport-https before executing update.

FROM ubuntu:14.04.4
RUN apt-get update && apt-get install -y apt-transport-https
RUN echo 'deb http://private-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.4.2.0 HDP main' >> /etc/apt/sources.list.d/HDP.list
RUN echo 'deb http://private-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/ubuntu14 HDP-UTILS main'  >> /etc/apt/sources.list.d/HDP.list
RUN echo 'deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/azurecore/ trusty main' >> /etc/apt/sources.list.d/azure-public-trusty.list

....
Rest of your Dockerfile.
techtabu
  • 23,241
  • 3
  • 25
  • 34
  • 4
    Your example shows running update THEN installing apt-transport-https. Can you clarify your answer? Seems like you update once to install, then in this specific example, add sources and update again from those new sources. The answer could be improved around this case. – Elijah Lynn Mar 20 '19 at 06:18
  • 1
    To update sources from https url apt-transport-https package should already exists. To make sure latest packages is being installed, we need to issue an update command before installing packages from ubuntu, so the first update is required. The second update is to install from sources that are added in the Dockerfile. – techtabu Mar 20 '19 at 20:17
  • 4
    You absolute diamond! `apt-get install -y apt-transport-https` – An0nC0d3r Jul 18 '19 at 14:29
  • 3
    In my case, the clock was out of sync due to https://github.com/docker/for-win/issues/5593, and running `sudo hwclock -s` in WSL2 fixed it for all docker builds since I'm running docker in WSL2. – Heath May 24 '20 at 04:51
  • this has been caused for me because of not adding `-y` to `apt-get install`. Didn't have to do with the `apt-transport-https` but pushed me into the right direction. So you might try to check for `-y` before adding potential unnessary pacakges. – Matthis Kohli Oct 11 '20 at 16:47
  • @Heath's solution worked for me under WSL2 – rdmtinez Dec 16 '20 at 12:28
34

I had to clean up my disk with docker system prune, I did it because I read about it on this other SO answer

Jonathan Morales Vélez
  • 3,030
  • 2
  • 30
  • 43
14

Just adding this in case it's of use to someone else. In my case I had to add the following line to the Dockerfile:

RUN apt-get -y update
Chris Claxton
  • 413
  • 6
  • 11
2

I encountered the same problem because my Dockerfile's FROM line refers to Ubuntu 20.10 whose support ended July 2021:

FROM ubuntu:groovy-20210416

Updating this to:

FROM ubuntu:focal-20211006

resolved the issue for me.

Andrew Santosa
  • 271
  • 2
  • 7
0

I had the same problem, solved it thanks to this answer :

https://superuser.com/questions/1423486/issue-with-fetching-http-deb-debian-org-debian-dists-jessie-updates-inrelease/1424377

You may want to add this line

RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list

before any apt-get command in the Dockerfile.

CivFan
  • 13,560
  • 9
  • 41
  • 58
oRabey
  • 13
  • 5
0

I was having trouble with a Dockerfile trying to apt-get install and getting return code 100. It turned out I had spelled the package name wrong. Hope this helps somebody.

Ed Greenberg
  • 209
  • 3
  • 12
-1

in my case the error was

The repository 'http://internalrepo/repos/internalrepo-name/1 Release' does not have a Release file.

adding [trusted=yes] before the deb package name fixed the issue.

i.e.

deb [trusted=yes] http://internalrepo/repos/internalrepo-name/1 /
Brian Burns
  • 20,575
  • 8
  • 83
  • 77
best wishes
  • 5,789
  • 1
  • 34
  • 59
-1

Check your time settings.
They may be not in sync with target http|https repository.

xillmera
  • 22
  • 3
-3

in some cases that might be a network issue and trying in few hours later or with an other network might fix that

Neo Mn
  • 150
  • 1
  • 12
-10

Had the same problem, fixed it using the following command

RUN apt -y update ; exit 0

purpull
  • 19