Reputation: 42768
Currently, I have the following docker file
FROM ubuntu:14.04
ADD . /var/www/html/xxx
RUN mkdir -p /tmp/debug1
WORKDIR /var/www/html/xxx
RUN mkdir -p /var/www/html/xxx/debug2
After docker-compose up -d
I went inside the container by using the following command
docker exec -it xxx_xxx_1 bash
To my suprise
/tmp/debug1
is created/var/www/html/xxx/debug2
is not createdHowever, if I went inside the container using
docker run -it xxx bash
What I realize is that
/tmp/debug1
is created/var/www/html/xxx/debug2
is createdMay I know why there is such behavior, after line WORKDIR?
Upvotes: 0
Views: 687
Reputation: 2125
This sounds like volumes being in play. Can you update your question with your compose file?
I assume that you have defined a volume in the compose file which mounts something to /var/www/html
If this is true, then this would explain what you see. When you run the container without compose, you see /var/www/html/xxx/debug2
because /var/www/html
contains the content originally created at docker build time. If you run it with compose, docker mounts a host directory or a docker volume onto /var/www/html
, in which case everything that was originally there get "invisible". If your volume/host-dir is empty, then /var/www/html
is also empty.
Upvotes: 2