コンテナが終了するとデータが失われます 質問する

コンテナが終了するとデータが失われます 質問する

Dockerのインタラクティブチュートリアルそしてよくある質問コンテナが終了するとデータが失われます。

ここで説明されているように Docker をインストールしました:http://docs.docker.io/en/latest/installation/ubuntulinuxUbuntu 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 

インタラクティブ セッションでもテストしましたが、結果は同じでした。何か忘れているのでしょうか?

編集: 新しいDockerユーザーにとって重要

@mohammed-noureldin や他の人が言ったように、実際にはこれはコンテナの終了ではありませ毎回新しいコンテナが作成されるだけです。

ベストアンサー1

必要がある専念コンテナに加えた変更を反映させてから実行します。これを試してください:

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

これでうまくいくはずです。

おすすめ記事