Docker volumes creates empty directory on the host

  docker, docker-volume, dockerfile, r

I am completely new to Docker, and am following this tutorial: .

Everything appears to build fine, and run fine (after I installed Docker desktop and Ubuntu and some WSL 2 thing), however using volumes does not appear to be working.

I can create an image, called "analysis" and confirm (by running R code) that it is doing what I want – creating a table and saving it as a CSV in the desired location on the container. However, when I try to run:

docker run -v ~/Documents/Internal/Personal_development/Personal_R/docker/results:/home/analysis/results analysis

I get a new results;C/ folder appearing in my docker/ directory. This is strange, but what is more confusing is that the folder is empty.

I was expecting that everything in home/analysis/results from the container would be copied to a new results folder in my docker/ directory. I also get the message:

enter image description here

All I want is to be able to easily sync files from the container onto my local machine. I have tried restarting my machine and Docker desktop and rebuilding the image, with no success. Any help would be very much appreciated!

Apologies if my language is incorrect throughout this post, following the above tutorial really is the first time I have ever tried/set-up Docker.

The Dockerfile I am using to build the image is below, and is built with:

docker build --build-arg WHEN=2019-01-06 -t analysis .

FROM rocker/r-ver:3.6.3


RUN mkdir /home/analysis

RUN R -e "options(repos = 
  list(CRAN = '${WHEN}/')); 

# Allows us to take a local script, and put it on the container
COPY myscript.R /home/analysis/myscript.R

# CMD is things we want to run straight after the container is launched
CMD cd /home/analysis 
  && mkdir results 
  && R -e "source('myscript.R')" 
  && Rscript -e "list.files('/home/analysis/results')"

# Run the below in the terminal in the dir where the Dockerfile is located
# -t analysis means "call this docker image 'analysis'"
# . means current WD
##docker build --build-arg WHEN=2019-01-06 -t analysis .
# docker run analysis

Source: Docker Questions