簡體   English   中英

Docker錯誤:無法找到包git

[英]Docker error: Unable to locate package git

我正在使用基於dockerfile/ubuntu的圖像nginx 在附加到docker容器的shell時

docker exec -it <container_id> /bin/bash

我想做一個git pull所以我嘗試安裝gitapt無法找到包:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM