I am Docker 20.10.17, build 100c701. Whenever I bind a local directory to a volume it doesn't show the volume using ls
.
(base) hell@Dell-Precision-T7910:~/Desktop/PhD/PHD/Nvidia Modulus/Modulus v22.03$ pwd
/home/hell/Desktop/PhD/PHD/Nvidia Modulus/Modulus v22.03
(base) hell@Dell-Precision-T7910:~/Desktop/PhD/PHD/Nvidia Modulus/Modulus v22.03$ ls
'Key features.txt' Modulus_examples Modulus_examples.tar.gz modulus_image_v22.03.tar.gz Modulus_source Modulus_source.tar.gz
(base) hell@Dell-Precision-T7910:~/Desktop/PhD/PHD/Nvidia Modulus/Modulus v22.03$ docker run --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -v ${pwd}:/examples -it modulus:22.03 bash
=============
== PyTorch ==
=============
root@b880211ba2ca:/examples# ls -a
. ..
root@b880211ba2ca:/examples# ls
My pwd
contains spaces and uppercase, I don't think there should a problem with spaces.
However, when I bind /home/
it works fine.
(base) hell@Dell-Precision-T7910:~/Desktop/PhD/PHD/Nvidia Modulus/Modulus v22.03$ docker run --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -v /home/hell/:/examples -it modulus:22.03 bash
=============
== PyTorch ==
=============
root@67b5dbfa0e10:/examples# ls
'2022-06-10 09-50-30.mkv' '2022-06-10 10-02-08.mkv' '2022-06-11 01-54-01.mkv' Documents MATLAB Pictures Templates Videos Zotero libreoffice
'2022-06-10 09-59-18.mkv' '2022-06-11 01-51-17.mkv' Desktop Downloads Music Public Untitled.ipynb 'VirtualBox VMs' anaconda3 snap
root@67b5dbfa0e10:/examples#
Please help me. BTW I am using Ubuntu 20.04 with RTX A5000 24GB.
CodePudding user response:
When your command uses -v ${pwd}:/examples
, the syntax ${pwd}
expands to an environment variable named pwd
. This probably expands to an empty string; you either need the environment variable PWD
(all uppercase, the case matters) or the output of the shell command pwd
. You say the path includes spaces; this makes it important to put the argument in double-quotes as well.
# using the $PWD environment variable
docker run -v "${PWD}:/example" ...
# using the `pwd` command
docker run -v "$(pwd):/example" ...