Mount local folder to nvidia tensorflow docker

I have been really struggling with this one.

I have downloaded the nvidia tensorflow:21.04-tf2-py3 image on my machine (Ubuntu 20.04), everything runs smoothly when I load the docker image except the fact that no matter what it always sends me to the /workspace, which by the way I have no idea where it is locally. It contains some nvidia examples and files.

I have been trying to access a git repository that I have downloaded locally (on my desktop) but to no avail, /home/<my username>/Desktop/GitRepo/<my repo>

What I have tried so far is:

go to the local folder and start the docker from there

sudo docker run --gpus all -it --rm -p 8888:8888 nvcr.io/nvidia/tensorflow:21.04-tf2-py3

then try to attach the local folder

sudo docker run --gpus all -it --rm -p 8888:8888 -v $(pwd):/testfolder nvcr.io/nvidia/tensorflow:21.04-tf2-py3

again with quotes

sudo docker run --gpus all -it --rm -p 8888:8888 -v "$(pwd):/testfolder" nvcr.io/nvidia/tensorflow:21.04-tf2-py3

then try to use the actual path

sudo docker run --gpus all -it --rm -p 8888:8888 -v "/home/<my username>/Desktop/GitRepo:/testfolder" nvcr.io/nvidia/tensorflow:21.04-tf2-py3

using the --mount option gives me other issues

sudo docker run --gpus all -it --rm -p 8888:8888 --mount src="$(pwd)",target="/testfolder" nvcr.io/nvidia/tensorflow:21.04-tf2-py3
sudo docker run --gpus all -it --rm -p 8888:8888 --mount src="/home/<my username>/Desktop/GitRepo/",target=/testfolder nvcr.io/nvidia/tensorflow:21.04-tf2-py3

docker: Error response from daemon: create
/home/myusername/Desktop/GitRepo/: "/home/myusername/Desktop/GitRepo/"
includes invalid characters for a local volume name, only
"[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a
host directory, use absolute path. See ‘docker run –help’.

Source: Docker Questions

LEAVE A COMMENT