Dockerfile
FROM ubuntu:18.04
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update && apt-get install -y \
curl \
git \
make \
sudo
RUN sudo useradd -m -p $(openssl passwd -1 1) me
USER me
WORKDIR /home/me
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash \
&& . $HOME/.nvm/nvm.sh && nvm install 8.12.0
RUN mkdir myvol && touch myvol/TEST
VOLUME myvol
Then build the image:
docker build ./ -t nodejs
Then start new container:
docker run -it --rm --name nodejs nodejs:latest bash
Now i can see that i have one anonymous volume created in the docker space:
/var/lib/docker/volumes/39459a1b2cf16e9d2dc2fe8fa5261186a02af75410a0e63f39e17e6e63b3ffe0
when i do:
sudo ls -asl /var/lib/docker/volumes/39459a1b2cf16e9d2dc2fe8fa5261186a02af75410a0e63f39e17e6e63b3ffe0/_data
I dont see the TEST file! The unnamed volume is empty!
Like the Docs say:
The docker run command initializes the newly created volume with any data that exists at the specified location within the base image.
Why i dont see the pre-existing content in the volume?