Reputation: 1549
I create the following image:
FROM node:14.7.0-alpine3.12
COPY ./test.txt /home/node/app/
using this command:
docker build . -t my-test
The image builds successfully, I run it like this:
docker run -it my-test
I inspect the content of the folder /home/node/app
using SSH.
So far all good.
I push the image to my docker registry.
I download the image, I run it and do the same operation. ALL GOOD. I can see the file test.txt
is there as expected.
I try the same in other machines, it all works good.
However, in some machines, I do the same operation but the file test.txt
is just not there. I double check the hashes, the image is correct, but the file is not in the image.
What's wrong?!
Upvotes: 4
Views: 4472
Reputation: 2235
If you're mounting a volume over an existing directory you will lose the original content of your image.
In your case it might be happening because a folder is mounted in one of the levels of the path /home/node/app
.
Use docker inspect <container>
to monitor the list of mounted volumes inside of your container ("Mounts"
fields).
You can also extract to output only Mounts using:
docker inspect -f '{{ .Mounts }}' <container>
Upvotes: 7