经常被各种环境问题折腾,docker出来后一直打算试试。昨天搞了个虚拟机折腾了一下,尼玛发现不支持32位的guest,重新搞了一个最新版本的64位ubuntu,终于可以pull image坑爹竟然又出现无法在host和guest之间share文件。

####Virtualbox shared folder
virtualbox share

Create mount point named share

junlung6@junlung6:~$mkdir ~/share

Assign mount point(~/share/) to virtualbox share folder ‘’share’’

sudo mount -t vboxsf share ~/share/ 

####Create docker image
1.pull original image from docker hub registry

junlung6@junlung6:~$sudo docker pull ubuntu

junlung6@junlung6:~$sudo docker images

junlung6@junlung6:~$sudo docker run -i -t ubuntu:latest /bin/bash

2.install app in container then exit

root@31e3359a74a2:/# apt-get install java
root@31e3359a74a2:/# apt-get install git
root@31e3359a74a2:/# which java
root@31e3359a74a2:/# exit

3.create image from container

sudo docker commit 31e3359a74a2 ubuntu-with-java

4.give new image a try

sudo docker run -i -t ubuntu-with-java /bin/bash
which java

5.run hello world

junlung6@junlung6:~$ sudo mount -t vboxsf share ~/share/
junlung6@junlung6:~$ ls ~/share/projects/
tomacat-helloworld
junlung6@junlung6:~$ sudo docker run -v ~/share/projects:/opt/projects ubuntu-with-java ls -l /opt/projects
total 4
drwxrwxrwx 1 root root 4096 May 13 08:29 tomacat-helloworld
junlung6@junlung6:~$ sudo docker run -v ~/share/projects:/opt/projects ubuntu-with-java java -jar /opt/projects/tomacat-helloworld/target/tomacat-helloworld-1.0-SNAPSHOT.jar
Hello World!