2016-10-28 219 views
1

安裝軟件包以下是一些出現在我的系統中的泊塢窗形象:無法在搬運工集裝箱

[email protected]:/home/labadmin# docker images 
REPOSITORY TAG  IMAGE ID   CREATED    SIZE 
ubuntu  14.04 1e0c3dd64ccd  13 days ago   187.9 MB 
ubuntu  latest 45bc58500fa3  5 weeks ago   126.9 MB 

我想在容器中安裝「了smartmontools」。但它拋出一個錯誤「無法找到包了smartmontools」如下:

[email protected]:/home/labadmin# docker run -it 1e0c3dd64ccd 
[email protected]:/# apt-get install smartmontools 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
E: Unable to locate package smartmontools 
[email protected]:/# exit 
exit 

但是,當我做同樣的在Ubuntu的機器,它正在。

[email protected]:/home/labadmin# apt-get install smartmontools 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
***smartmontools is already the newest version.*** 
0 upgraded, 0 newly installed, 0 to remove and 542 not upgraded. 
[email protected]:/home/labadmin# 

Ubuntu Containers和Ubuntu系統有什麼區別?什麼阻止軟件包安裝在容器中?

我的要求是創建一些公用事業與Ubuntu OS中的集裝箱爲基礎的圖像:

FROM ubuntu:14.04 
RUN apt-get update && apt-get install -y smartmontools 
+0

可上網容器內? – Rao

+0

是的,工作,但看起來像DNS問題。 –

+0

你的發現是什麼? – Rao

回答

0

以下程序已經幫我解決這個問題:

[email protected]:/home/labadmin# docker run busybox ping -c 2 192.203.230.10 
PING 192.203.230.10 (192.203.230.10): 56 data bytes 
64 bytes from 192.203.230.10: seq=0 ttl=56 time=66.724 ms 
64 bytes from 192.203.230.10: seq=1 ttl=56 time=54.786 ms 
--- 192.203.230.10 ping statistics --- 
2 packets transmitted, 2 packets received, 0% packet loss 
round-trip min/avg/max = 45.815/56.947/66.724 ms 

當您嘗試使用容器ping到google.com時,由於DNS問題而無法訪問。

[email protected]:/home/labadmin# docker run busybox nslookup google.com 
Server: 8.8.8.8 
Address 1: 8.8.8.8 

nslookup: can't resolve 'google.com' 

找出在你的機器使用的DNS服務器:

[email protected]:/home/labadmin# nm-tool |grep DNS 
    DNS:    172.24.100.50 
    DNS:    10.1.100.50 

執行相同的加入DNS IP:

[email protected]:/home/labadmin# docker run --dns 172.24.100.50 busybox nslookup google.com 
Server: 172.24.100.50 
Address 1: 172.24.100.50 indc01.radisys.com 

Name:  google.com 
Address 1: 2607:f8b0:4009:80c::200e ord36s01-in-x0e.1e100.net 
Address 2: 172.217.4.110 ord36s04-in-f14.1e100.net 

要解決它永久以下內容添加到新的文件:

[email protected]:/home/labadmin# cat /etc/docker/daemon.json 
{ 
    "dns" : ["172.24.100.50", "8.8.8.8"] 
} 

上泊塢窗DNS配置的更多信息:https://docs.docker.com/engine/userguide/networking/configure-dns/

重新啓動搬運工服務:

[email protected]:/home/labadmin# docker run -it e02e811dd08f 
/# ping google.com 
PING google.com (172.217.4.238): 56 data bytes 
64 bytes from 172.217.4.238: seq=0 ttl=47 time=251.506 ms 
64 bytes from 172.217.4.238: seq=1 ttl=47 time=245.621 ms 
^C 
--- google.com ping statistics --- 
2 packets transmitted, 2 packets received, 0% packet loss 
round-trip min/avg/max = 245.621/257.113/272.586 ms 
/# 

欲瞭解更多信息:

[email protected]:/home/labadmin# sudo service docker restart 
docker stop/waiting 
docker start/running, process 22291 

[email protected]:/home/labadmin# docker run busybox nslookup google.com 
Server: 172.24.100.50 
Address 1: 172.24.100.50 indc01.radisys.com 

Name:  google.com 
Address 1: 2607:f8b0:4009:801::200e ord30s31-in-x0e.1e100.net 
Address 2: 172.217.4.238 ord30s31-in-f14.1e100.net 

通過運行容器檢查它https://robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

0

當您通過手動運行容器測試你不更新緩存蒙山apt-get update因此Unable to locate package錯誤

但你Dockerfile例子應該工作

+0

root @ labadmin-VirtualBox:〜/ RAGHU#docker build -t mont:1.1。 發送構建上下文到Docker守護進程209.5 MB 第1步:從ubuntu:14。04 ---> 1e0c3dd64ccd 第2步:運行apt-get更新&&的apt-get安裝-y了smartmontools --->在616f62c55440 更新/ InRelease 讀取軟件包列表... 大廈的依賴關係樹正在運行... 正在讀取狀態信息... E:無法找到包smartmontools **命令'/ bin/sh -c apt-get update && apt-get install -y smartmontools'返回了一個非零代碼:100 ** –

+0

嘗試使用--no-cache和--pull來確定。這將確保圖像是最新的,並會使可能包含無效數據的緩存失效 –