Cannot install packages inside docker Ubuntu image
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
From the docs in May 2017 2018 2019 2020 2021 2022
Always combine
RUN apt-get update
withapt-get install
in the sameRUN
statement, for example
RUN apt-get update && apt-get install -y package-bar
(...)
Using
apt-get update
alone in aRUN
statement causes caching issues and subsequentapt-get install
instructions fail.(...)
Using
RUN apt-get update && apt-get install -y
ensures your Dockerfile installs the latest package versions with no further coding or manual intervention. This technique is known as “cache busting”.