尽管 Docker 的 Interactive tutorial和 faq容器退出时我丢失了数据。
我已经安装了 Docker,如下所述:http://docs.docker.io/en/latest/installation/ubuntulinux在 ubuntu 13.04 上没有任何问题。
但退出时会丢失所有数据。
iman@test:~$ sudo docker version
Client version: 0.6.4
Go version (client): go1.1.2
Git commit (client): 2f74b1c
Server version: 0.6.4
Git commit (server): 2f74b1c
Go version (server): go1.1.2
Last stable version: 0.6.4
iman@test:~$ sudo docker run ubuntu ping
2013/10/25 08:05:47 Unable to locate ping
iman@test:~$ sudo docker run ubuntu apt-get install ping
Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
iputils-ping
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.1 kB of archives.
After this operation, 143 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main iputils-ping amd64 3:20101006-1ubuntu1 [56.1 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 56.1 kB in 0s (195 kB/s)
Selecting previously unselected package iputils-ping.
(Reading database ... 7545 files and directories currently installed.)
Unpacking iputils-ping (from .../iputils-ping_3%3a20101006-1ubuntu1_amd64.deb) ...
Setting up iputils-ping (3:20101006-1ubuntu1) ...
iman@test:~$ sudo docker run ubuntu ping
2013/10/25 08:06:11 Unable to locate ping
iman@test:~$ sudo docker run ubuntu touch /home/test
iman@test:~$ sudo docker run ubuntu ls /home/test
ls: cannot access /home/test: No such file or directory
我还使用交互式 session 对其进行了测试,结果相同。我是不是忘记了什么?
编辑:对 Docker 新用户很重要
正如@mohammed-noureldin 和其他人所说,实际上这不是 容器退出。每次它只是创建一个新容器。
您需要 commit您对容器所做的更改然后运行它。试试这个:
sudo docker pull ubuntu
sudo docker run ubuntu apt-get install -y ping
然后使用以下命令获取容器 id:
sudo docker ps -l
提交对容器的更改:
sudo docker commit <container_id> iman/ping
然后运行容器:
sudo docker run iman/ping ping www.google.com
这应该可行。
我是一名优秀的程序员,十分优秀!