コンテナ内のcentosに入ります。
vagrant@vagrant-ubuntu-trusty-64:~$ sudo docker run -i -t centos /bin/bash
[root@83a948642dbe /]# touch hello.text
[root@83a948642dbe /]# ls
anaconda-post.log dev hello.text lib media opt root sbin sys usr
bin etc home lib64 mnt proc run srv tmp var
[root@83a948642dbe /]# exit
exit
vagrant@vagrant-ubuntu-trusty-64:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
83a948642dbe centos “/bin/bash” 2 minutes ago Exited (0) About a minute ago elated_swartz
45e5501bd8ef centos “free -s 3” 10 minutes ago Up 10 minutes compassionate_mccarthy
0b8011965ea0 centos “echo ‘hello world'” 19 minutes ago Exited (0) 19 minutes ago romantic_kapitsa
c6490f99e041 hello-world “/hello” About an hour ago Exited (0) About an hour ago distracted_wilson
1abf8bdb8845 hello-world “/hello” About an hour ago Exited (0) About an hour ago sad_colden
sudo docker commitでcontainerからimageを作る。
vagrant@vagrant-ubuntu-trusty-64:~$ sudo docker commit 83a
sha256:ab93f4f1679d8efa1843606ea3d8741b35fe3f9b73e1ddb8acbfbd2ddf25f468
vagrant@vagrant-ubuntu-trusty-64:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 4ab4c602aa5e 2 days ago 1.84kB
centos latest 5182e96772bf 4 weeks ago 200MB
vagrant@vagrant-ubuntu-trusty-64:~$ sudo docker run -i -t ab9 /bin/bash
[root@5e92b8233188 /]# ls
anaconda-post.log dev hello.text lib media opt root sbin sys usr
bin etc home lib64 mnt proc run srv tmp var
なるほどなるほど。