dockerfile是否可以使用docker-compose.yml文件中定义的仅数据容器?

在我的docker-compose.yml文件中,我首先为数据容器定义一个服务,其容量为/ data:

data: image: library/ubuntu:14.04 volumes: - /data command: tail -F /dev/null 

然后我有一个有Dockerfile的第二个服务。

 test: build: context: . dockerfile: "Dockerfile" volumes_from: - data:rw depends_on: - data 

在那个Dockerfile中,我想写入来自数据服务的数据卷(例如“RUN touch /data/helloworld.txt”)。 但是,当我运行docker-compose,然后执行testing以查看/ data的内容时,该目录是空的。 如果我等待在容器运行之后(例如,通过exec)等待“touch /data/helloworld.txt”,那么文件存在于/数据卷中,并且可以从任一容器访问。

有没有一种方法让Dockerfile使用docker-compose.yml中定义的另一个容器中的卷?