克隆的git不在Docker卷中?
我使用下面的Dockerfile:
FROM centos VOLUME ["apitests"] RUN su RUN yum -y install git RUN git clone https://github.com/Human-Connection/CUBE-arduino-yun.git /apitests/
然后我build立我的形象
docker build -t apitesting .
并用一个shell启动一个容器
docker run -ti apitesting /bin/bash
现在我发现/ apitests在容器内。 但是我找不到克隆的git数据。
我究竟做错了什么?
在数据存在之后定义VOLUME
。 Docker自动使用图像中的任何内容填充VOLUME
。 开始/apitests
是空的。
FROM centos RUN yum -y install git RUN git clone https://github.com/Human-Connection/CUBE-arduino-yun.git /apitests/ VOLUME ["apitests"]
另外, RUN su
自己的步骤什么也不做。 每个RUN
在它自己的容器中启动。 在RUN
步骤之间进行的唯一事情是写入磁盘并随后提交到图像层。
这适用于我:在你的目录中创build并加载数据之后定义卷。
FROM centos RUN yum -y install git RUN mkdir /apitests RUN git clone https://github.com/Human-Connection/CUBE-arduino-yun.git /apitests/ VOLUME /apitests