可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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?
回答1:
It is because there is no package cache in the image, you need to run:
apt-get -qq update
before installing packages, and if your command is in a Dockerfile, you'll then need:
apt-get -qq -y install curl
回答2:
From the docs in March 2017:
Always combine RUN apt-get update with apt-get install in the same RUN statement, for example
RUN apt-get update && apt-get install -y package-bar
(...)
Using apt-get update alone in a RUN statement causes caching issues and subsequent apt-get install instructions fail.
回答3:
add following command in Dockerfile: RUN apt-get update