Docker Community Forums

Share and learn in the Docker community.

Why VOLUME command in Dockerfile does not work in my env?


(wangyumi) #1

Hi Gurus,

Here is what I am trying to do. It is a very simple sample from “The docker book”. But I found nothing after I run the container:

core@core-01 ~/fetcher $ uname -a
Linux core-01 3.16.2+ #2 SMP Tue Oct 7 01:50:34 UTC 2014 x86_64 Intel® Core™ i5-4210U CPU @ 1.70GHz GenuineIntel GNU/Linux
core@core-01 ~/fetcher $ docker --version
Docker version 1.2.0, build fa7b24f
core@core-01 ~/fetcher $ cat Dockerfile
FROM ubuntu:14.04
MAINTAINER Wangyumi
ENV REFRESHED_AT 2014-10-28
RUN apt-get -yqq update
RUN apt-get -yqq install wget
VOLUME [ “/var/lib/tomcat7/webapps/” ]
WORKDIR /var/lib/tomcat7/webapps/
ENTRYPOINT [ “wget” ]
CMD [ “-?” ]
core@core-01 ~/fetcher $ ls -l /var/lib/tomcat7
total 0
drwxrwxrwx 1 root root 0 Oct 28 09:30 webapps
core@core-01 ~/fetcher $ sudo docker build -t fetcher .
Sending build context to Docker daemon 2.56 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu:14.04
—> 5506de2b643b
Step 1 : MAINTAINER Wangyumi
—> Using cache
—> 0bbce8b832ae
Step 2 : ENV REFRESHED_AT 2014-10-28
—> Using cache
—> 2f4c84f297c2
Step 3 : RUN apt-get -yqq update
—> Using cache
—> e1397d045ab7
Step 4 : RUN apt-get -yqq install wget
—> Using cache
—> 6ef898dc1ce3
Step 5 : VOLUME [ “/var/lib/tomcat7/webapps/” ]
—> Using cache
—> 7271be9dbcdb
Step 6 : WORKDIR /var/lib/tomcat7/webapps/
—> Using cache
—> bcaff8e8874a
Step 7 : ENTRYPOINT [ “wget” ]
—> Using cache
—> c971b18ed0c1
Step 8 : CMD [ “-?” ]
—> Using cache
—> 9e1c143cb35a
Successfully built 9e1c143cb35a
core@core-01 ~/fetcher $ docker run -t -i --name fetcher fetcher https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war
–2014-10-29 01:37:11-- https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war
Resolving tomcat.apache.org (tomcat.apache.org)… 140.211.11.131, 192.87.106.229, 140.211.11.131, …
Connecting to tomcat.apache.org (tomcat.apache.org)|140.211.11.131|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 4606 (4.5K)
Saving to: ‘sample.war’

100%[====================================================================================================================>] 4,606 --.-K/s in 0s

2014-10-29 01:37:12 (13.7 MB/s) - ‘sample.war’ saved [4606/4606]

core@core-01 ~/fetcher $ ls -l /var/lib/tomcat7/webapps
total 0

Any ideas? Thanks in advance.

/Wangyumi


(wangyumi) #2

It seems I understand now.
The files wrote to the volume can be accessed by container only by --volumes-from


(Sven Dowideit) #3

yup, or if you where to run your container like:

docker run -t -i --name fetcher -v /tmp:/var/lib/tomcat7/webapps fetcher https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war

so that your local dir (/tmp) is mounted at that volume mount point

or, there is a PR that will eventually allow you to run what you did above, and then

docker cp fletcher:/var/lib/tomcat7/webapps/sample.war .


(wangyumi) #4

pretty cool.

It will be better if I can:
docker cp sample.war fletcher:/var/lib/tomcat7/webapps/

Thanks.