2
当我从Docker INDEX下载一个全新的Ubuntu:12.04容器时,它没有任何工作。它甚至没有sudo或lsb_release。有没有人有任何想法为什么或如何让容器进入可用的状态?谢谢。Docker Ubuntu 12.04
当我从Docker INDEX下载一个全新的Ubuntu:12.04容器时,它没有任何工作。它甚至没有sudo或lsb_release。有没有人有任何想法为什么或如何让容器进入可用的状态?谢谢。Docker Ubuntu 12.04
看到你做了什么并且知道你的期望会很有趣。但这里是一个工作的例子,也许这有助于:
# get the image
docker pull ubuntu
# run pwd in the image and see that you are in "/"
docker run ubuntu pwd
/
# curl a website and see that curl is not installed
docker run ubuntu curl www.google.com
2014/05/22 07:52:42 exec: "curl": executable file not found in $PATH
# update apt-get
docker run ubuntu apt-get update
# Now attention: Docker will not change the base image Ubuntu!
# So apt is not updated in your Ubuntu image! Instead, Docker
# will create a new container every time you run a command. Let's see
# how the new container is called (your CONTAINER ID will be different!):
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS
a7ae5dae6dd8 ubuntu:12.04 apt-get update 53 seconds ago Exited (0) 40 seconds ago nostalgic_lumiere
# So container a7ae5dae6dd8 is Ubuntu + apt-get update. Give it
# a name and save it as a new image:
docker commit a7ae my-ubuntu
# Now install curl in my-ubuntu
docker run my-ubuntu apt-get install -y curl
# And again: the image my-ubuntu is not changed! Instead we have a new
# container which has curl installed:
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS
e07118069479 my-ubuntu:latest apt-get install -y c About a minute ago Exited (0) 45 seconds ago naughty_wozniak
a7ae5dae6dd8 ubuntu:12.04 apt-get update 9 minutes ago Exited (0) 9 minutes ago nostalgic_lumiere
# Let's save this container as our image:
docker commit e071 my-ubuntu
# and now run curl on my-ubuntu:
docker run my-ubuntu curl www.google.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 258 100 258 0 0 10698 0 --:--:-- --:--:-- --:--:-- 25800
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.de/?gfe_rd=cr&ei=ZrB9U4_eH4HW_AbjvoG4Ag">here</A>.
</BODY></HTML>
我希望能帮助看看Docker是如何工作的。为了让图像进入一个可以使用的状态(安装你的包和东西),你当然不会像上面那样手动完成它。相反,你将创建一个Dockerfile建立形象:
FROM Ubuntu
RUN apt-get update
RUN apt-get install -y curl
,并建立类似docker build . -t my-ubuntu
想要的图像。
请首先确定“可以使用的状态”。对我来说,bash可以工作,你可以通过'apt-get'获取所有精确的依赖关系。 – shawnzhu
这个问题似乎是无关紧要的,因为它是关于一般计算而不是编程。 –
请列出您输入的命令,并描述它对“没有任何作用”的含义。显然它看起来已经下载了。 –