我正在尝试将主机目录挂载到 Docker 容器中,以便在主机上完成的任何更新都反映到 Docker 容器中。
我在哪里做错了什么。这是我所做的:
kishore$ cat Dockerfile
FROM ubuntu:trusty
RUN apt-get update
RUN apt-get -y install git curl vim
CMD ["/bin/bash"]
WORKDIR /test_container
VOLUME ["/test_container"]
kishore$ tree . ├── Dockerfile └── main_folder ├── tfile1.txt ├── tfile2.txt ├── tfile3.txt └── tfile4.txt
1 directory, 5 files kishore$ pwd /Users/kishore/tdock
kishore$ docker build --tag=k3_s3:latest .
Uploading context 7.168 kB Uploading context Step 0 : FROM ubuntu:trusty ---> 99ec81b80c55 Step 1 : RUN apt-get update ---> Using cache ---> 1c7282005040 Step 2 : RUN apt-get -y install git curl vim ---> Using cache ---> aed48634e300 Step 3 : CMD ["/bin/bash"] ---> Running in d081b576878d ---> 65db8df48595 Step 4 : WORKDIR /test_container ---> Running in 5b8d2ccd719d ---> 250369b30e1f Step 5 : VOLUME ["/test_container"] ---> Running in 72ca332d9809 ---> 163deb2b1bc5 Successfully built 163deb2b1bc5 Removing intermediate container b8bfcb071441 Removing intermediate container d081b576878d Removing intermediate container 5b8d2ccd719d Removing intermediate container 72ca332d9809
kishore$ docker run -d -v /Users/kishore/main_folder:/test_container k3_s3:latest
c9f9a7e09c54ee1c2cc966f15c963b4af320b5203b8c46689033c1ab8872a0ea
kishore$ docker run -i -t k3_s3:latest /bin/bash
root@0f17e2313a46:/test_container# ls -al total 8 drwx------ 2 root root 4096 Apr 29 05:15 . drwxr-xr-x 66 root root 4096 Apr 29 05:15 ..
root@0f17e2313a46:/test_container# exit exit
kishore$ docker -v
Docker version 0.9.1, build 867b2a9
- 我不知道如何检查 boot2docker 版本
问题,面临的问题:
- 我如何需要将 main_folder 链接到 docker 容器内的 test_container 文件夹?
- 我需要自动做到这一点。在不真正使用命令的情况下如何做到这一点
run -d -v
? - 如果 boot2docker 崩溃了怎么办?Docker 文件存储在哪里(Dockerfile 除外)?