Strange behavior with VOLUME in inherited image
I have 2 Dockerfile
s.
Here is a
:
FROM ubuntu:14.04
RUN mkdir /opt/test
RUN touch /opt/test/test.txt
VOLUME /opt/test
Here is b
:
FROM a
RUN touch /opt/test/b.txt
Then I create both of my images:
cd a && sudo docker build -t a . && cd ../b && sudo docker build -t b .
And I ran the b
image:
sudo docker run -i --rm --name b -t b /bin/bash
In my container, b
I usually don't see /opt/test/b.txt
my image b
:
root@4db094589f0d:/# ls /opt/test/
test.txt
If I remove VOLUME /opt/test
from mine a
Dockerfile
, then I will see mine correctly /opt/test/b.txt
.
Can anyone explain to me why?
source to share
Changes to data volume will not be included on image refresh
You can use a script to create the file if it's empty.
source to share