I'm trying to copy the folder and contents from a source to a Docker container using an image. I built the image from my Dockerfile.
RUN useradd -m -s /bin/bash user1 && \
ln -s /foo /home/user1/foo
RUN mkdir /foo && && chown -R user1:user1 /foo
VOLUME /foo
After I build the Docker image, I run these commands to create a container.
docker run -it
--name container_name \
--mount "type=bind,source=$(pwd)/$FOLDER/container_foo,destination=/foo/" \
dockerimage:tag
The files from the source folder /foo
isn't in the /container_foo
. I checked by doing docker exec -it container_ID /bin/bash
and confirmed that the files aren't there.
EDIT :
I just found out that mount
only goes one way, exposing local host files/folder to the docker container. It doesn't copy the files inside of the docker container to the local folder when mounting. I removed creating the /foo
directory from RUN
and VOLUME
. Instead I did this in the Dockerfile.
COPY --chown=user1:user1 foo/ foo/
And I was able to copy the files from source. Now I just need to copy it from there to container_foo
when doing the docker run ...
command.