Cannot install packages inside docker Ubuntu image

Developer picture Developer · Dec 3, 2014 · Viewed 181.2k times · Source

I installed Ubuntu 14.04 image on docker. After that, when I try to install packages inside the ubuntu image, I'm getting unable to locate package error:

apt-get install curl

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package curl

How to fix this error?

Answer

ISanych picture ISanych · Dec 3, 2014

It is because there is no package cache in the image, you need to run:

apt-get update

before installing packages, and if your command is in a Dockerfile, you'll then need:

apt-get -y install curl

To suppress the standard output from a command use -qq. E.g.

apt-get -qq -y install curl