I’m trying to run this dolfinx demo file, using docker. My OS is Ubuntu 20.04 LTS. In order to do so, I tried to copy my local version of the demo file (that is in the folder dolfinx-demos) into the docker container, executing the following commands:
Unfortunately, nothing gets copied in the container folder (ls command gives an empty list):
sudo docker exec -ti container-id bash
root@container-id:~# cd helmholtz
root@container-id:~/helmholtz# ls
root@container-id:~/helmholtz#
What am I doing wrong? How can I pass files from host to container? With the help of this guide, I had no problem in doing that with the stable version of fenics, but it seems that in dolfinx it is different.
docker run -ti -v $(pwd):/root/shared -w /root/shared dolfinx/dolfinx
Here -v shares a volume, $(pwd) the current folder you are in, to the location root shared in the docker container. -w indicates what the working directory should be, which is where the docker container will start. I have set this to the directory you want to share.
Thank you very much @dokken ! Your help is precious as always! Just one other question: is /root/shared a “special” Docker folder? Why can I share files only with that folder?
You can share to any folder inside the docker container. The reason for choosing this path is:
The user in the docker container is the root user, therefore one would like to share it to some path that the user owns.
The reason for calling the directory shared and not something else, is to remind you that the files in this folder are those from your computer. If you delete a file in this folder, it is also deleted on your system.