克隆的git不在Docker Volume中?

Mar*_*arc 2 docker docker-volume

我使用以下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/
Run Code Online (Sandbox Code Playgroud)

然后我建立我的形象

docker build -t apitesting .
Run Code Online (Sandbox Code Playgroud)

并启动一个带有shell的容器

docker run -ti apitesting /bin/bash
Run Code Online (Sandbox Code Playgroud)

现在我在容器中找到/ apitests.但我找不到克隆的git数据.

我究竟做错了什么?

Mat*_*att 6

VOLUME在数据存在之后定义.Docker auto VOLUME使用图像中的任何内容填充a .一开始/apitests是空的.

FROM centos
RUN yum -y install git
RUN git clone https://github.com/Human-Connection/CUBE-arduino-yun.git /apitests/
VOLUME ["apitests"]
Run Code Online (Sandbox Code Playgroud)

而且,RUN su因为它自己的步骤什么也没做.每个都RUN在它自己的容器中启动.在RUN步骤之间进行的唯一事情是写入磁盘并随后提交到图像层的内容.