Cannot install packages inside docker Ubuntu image

匿名 (未验证) 提交于 2019-12-03 02:44:02

问题:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!