[英]Docker error: Unable to locate package git
我正在使用基於dockerfile/ubuntu
的圖像nginx
。 在附加到docker容器的shell時
docker exec -it <container_id> /bin/bash
我想做一個git pull
所以我嘗試安裝git
但apt
無法找到包:
root@a71e45d5cd40:/# apt-get install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package git
我們如何從該圖像安裝git
,為什么它會丟失?
cat /etc/apt/sources.list
deb http://httpredir.debian.org/debian wheezy main
deb http://httpredir.debian.org/debian wheezy-updates main
deb http://security.debian.org wheezy/updates main
deb http://nginx.org/packages/mainline/debian/ wheezy nginx
cat /etc/apt/sources.list.d/*
cat: /etc/apt/sources.list.d/*: No such file or directory
apt-cache madison git
N: Unable to locate package git
發生這種情況是因為apt存儲庫尚未更新,通常的做法是在創建基本映像可能正在執行的映像后清理apt存儲庫和tmp文件。
要解決此問題,您需要在安裝git之前運行apt-get update
,如果安裝行更改,最好將更新和安裝命令同時組合到更新上的緩存中:
RUN apt-get update && apt-get install -y git
使用-y
可以方便地自動回答所有問題的“是”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.