Fenics on docker on MACOSX, the shared folder is empty

I installed Fenics on Docker on my MacBook Pro 16 inch, OS X Catalina.

My shared folder is physically on the following location
“/Users/‘myname’/Desktop/my-work-directory”

I opened that folder in a terminal and used the following command:

“docker run -ti -v ${pwd}:/home/fenics/shared quay.io/fenicsproject/stable

and Fenics started normally

"

FEniCS stable version image

Welcome to FEniCS/stable!

This image provides a full-featured and optimized build of the stable
release of FEniCS.

To help you get started this image contains a number of demo
programs. Explore the demos by entering the ‘demo’ directory, for
example:

cd ~/demo/python/documented/poisson
python3 demo_poisson.py "

When I ‘cd’ in the shared folder
“home/fenics/shared” I see nothing inside even if I have a .py script on my host’s “my-work-directory”

So I can not run my own scripts or plot results.

Thank you for any help.

For the record I read the posts related to this and followed the recommendations to no avail.

See for instance:

Thanks for the reply. This did not fix the issue.

when I execute
" eval “$(docker-machine env dev)” "
I get:
“Docker machine “dev” does not exist. Use “docker-machine ls” to list machines. Use “docker-machine create” to add a new one”

the command
“docker-machine ls”
gives
“NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS”

I am not sure what do I need to create…

Following the suggestion:
“path=(pwd); echo {path}”
works and shows the correct path of the current directory

“path=(pwd); docker run -ti -v {path}:/home/fenics/shared quay.io/fenicsproject/stable:latest
or any docker command after “path=$(pwd);” gives
“zsh: command not found: docker”

At this point I have to open a new terminal in order the docker command
to work again and start fenics.

Note that I also get
“zsh: command not found: docker”
If I input
“docker run -ti -v (pwd):/home/fenics/shared quay.io/fenicsproject/stable:latest" instead of "docker run -ti -v {pwd}:/home/fenics/shared quay.io/fenicsproject/stable:latest

Thanks for your help

Please encapsulate the commands above with ` as they are not readable when formatted as markdown . For formatting blocks use ```

I hope the format is ok now.

when I execute
eval “$(docker-machine env dev)”
I get:

“Docker machine “dev” does not exist. Use “docker-machine ls” to list machines. Use “docker-machine create” to add a new one”

the command

“docker-machine ls”

gives

“NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS”

I am not sure what do I need to create…

Following the suggestion:

path=$(pwd); echo ${path}

works and shows the correct path of the current directory

path=$(pwd);

acompanied by any docker command gives

“zsh: command not found: docker”

At this point I have to open a new terminal in order the docker command
to work again and start fenics.

Note that I also get

“zsh: command not found: docker”

If I input

docker run -ti -v $(pwd):/home/fenics/shared -w /home/fenics/shared quay.io/fenicsproject/stable:lates

instead of

docker run -ti -v ${pwd}:/home/fenics/shared -w /home/fenics/shared quay.io/fenicsproject/stable:lates

Thanks for your help

As this has nothing to do with the actual fenics image, could you try the following:

docker run -v $(pwd):/home/shared -w /home/shared -ti ubuntu:20.04

Also try with ${pwd} please.

Does that give you the shared volume?
If not, how did you install docker? Did you follow: https://docs.docker.com/docker-for-mac/
See also: https://docs.docker.com/docker-for-mac/troubleshoot/#volume-mounting-requires-file-sharing-for-any-project-directories-outside-of-users

Following your command I get

" docker: invalid reference format.

See ‘docker run --help’."

I installed docker stable for Mac yes from the link you shared, .dmg file…

As far as I understand the file on the host I want to share with fenics is in /Users
“/Users/‘myname’/Desktop/my-work-directory”
so the link you sent me said it should work.

Thank you

What if you encapsulate /home/shared with string quotations, such as “/home/shared”

with `${pwd}’ it works

docker run -v ${pwd}:/home/shared -w /home/shared -ti ubuntu:20.04

I get:

" Unable to find image ‘ubuntu:20.04’ locally

20.04: Pulling from library/ubuntu

d72e567cc804: Pull complete

0f3630e5ff08: Pull complete

b6a83d81d1f4: Pull complete

Digest: sha256:bc2f7250f69267c9c6b66d7b6a81a54d3878bb85f1ebb5f951c896d13e6ba537

Status: Downloaded newer image for ubuntu:20.04 "

And it shares your directory?

The directory is still empty. So no.
After your command, I am not in fenics…should not I be in fenics? in any case shared empty.

Using:
my-work-directory %
docker run -v ${pwd}:/home/fenics/shared -ti quay.io/fenicsproject/stable:latest

fenics runs but shared folder again still empty…

Thanks

The command I suggested here should mount you in the directory /home/shared, which should contain the files you are sharing. I removed FEniCS from this command on purpose, to show you that this is simply your docker not being set up correctly.

Please run the actual commands I ask you to run.

I did run the command. Shared still empty.

Then, as I have said multiple times now, you have not set up docker correctly.
Please go through the steps here to ensure that you have done things correctly:


try for instance:
$ docker run -it -v ~/Desktop:/Desktop r-base bash

and check that your directory has been shared in the folder Desktop

So I followed the above:

@MacBook-Pro-2 my-work-directory % docker run -it -v ~/Desktop:/Desktop r-base bash

root@9d6fb39da3f8:/# ls

bin Desktop etc lib media opt root sbin sys usr
boot dev home lib64 mnt proc run srv tmp var

From here I can cd to my directory inside Desktop and is not empty anymore. I see my files!

I have also added the path to my shared folder in the docker app by “+” in preferences -resources- file sharing in the docker app and restarted it…

I ran your command with a terminal opened on my desktop work folder

docker run -v ${pwd}:/home/shared -w /home/shared -ti ubuntu:20.04

and shared is still empty in docker.

I also opened fenics and looked inside the shared folder there, still empty.

Any suggestions?

Thanks

Add the full path to what you want to share instead of using PWD.

Just did but shared folder in docker is still empty.
Thanks

Try to share it to /Desktop, as that worked above…
I cannot be of further assistance, as you have the commands to share a directory to the folder /Desktop.

Fenics does not see this /Desktop folder though, so I can not use it…Or I did not understand exactly what you mean. Could you be more specific?

Is there any other way to move out files from inside FEniCS Docker to the host so at least I can process output files?

Thanks

So, according to you, the following worked: docker run -it -v ~/Desktop:/Desktop r-base bash
On my own computer, the desktop only has a test directory, thus it shows the following:

jsd55@desktoppc:~/Documents/src/dolfinx/python/demo/pyvista$ docker run -it -v ~/Desktop:/Desktop r-base bash
root@d5400c7477fa:/# ls Desktop/
test

Similarly I can do this with the Ubuntu 20.04 image:

jsd55@desktoppc:~/Documents/src/dolfinx/python/demo/pyvista$ docker run -it -v ~/Desktop:/Desktop ubuntu:20.04
root@8f591686e727:/# ls Desktop/
test

or with the fenics image

jsd55@desktoppc:~/Documents/src/dolfinx/python/demo/pyvista$ docker run -it -v ~/Desktop:/Desktop quay.io/fenicsproject/stable:latest
# FEniCS stable version image

Welcome to FEniCS/stable!

This image provides a full-featured and optimized build of the stable
release of FEniCS.

To help you get started this image contains a number of demo
programs. Explore the demos by entering the 'demo' directory, for
example:

    cd ~/demo/python/documented/poisson
    python3 demo_poisson.py
fenics@e1de04266cfb:~$ ls 
.bash_logout               .bashrc                    .profile                   WELCOME                    fenics.env.conf            shared/                    
.bash_profile              .config/                   .sudo_as_admin_successful  demo/                      local/                     
fenics@e1de04266cfb:~$ ls /Desktop/
test

As you can see when using the fenics image, your starting location is home/fenics, while your shared folder is located at /Desktop. Thus changing it to:

jsd55@desktoppc:~/Documents/src/dolfinx/python/demo/pyvista$ docker run -it -v ~/Desktop:/home/fenics/shared quay.io/fenicsproject/stable:latest
# FEniCS stable version image

Welcome to FEniCS/stable!

This image provides a full-featured and optimized build of the stable
release of FEniCS.

To help you get started this image contains a number of demo
programs. Explore the demos by entering the 'demo' directory, for
example:

    cd ~/demo/python/documented/poisson
    python3 demo_poisson.py
fenics@05549cf91a6e:~$ ls
WELCOME  demo  fenics.env.conf  local  shared
fenics@05549cf91a6e:~$ ls shared/
test
fenics@05549cf91a6e:~$ 

Now, the shared folder is inside /home/fenics/shared.