Installation problems

Agree, something like this should work.

@Oskar in all your four examples in your first answer you forgot to specifiy the container you want to start, i.e. you forgot the quay.io/fenicsproject/stable:latest at the end of the command.

And I wouldn’t try to dig deeper into conda, maybe the packages are just no available for Windows or so.

Edit: I just noticed that /home/shared doesn’t exist per default in the quay-container? Isn’t that a problem? If so, maybe try /home/fenics instead.

This also does prompt the following:

PS C:\Windows\system32> docker run -ti -v "C:\Users\neuma\fenics":/home/shared quay.io/fenicsproject/stable:latest
docker: invalid reference format.
See 'docker run --help'.
PS C:\Users\neuma> docker run -ti -v "C:\Users\neuma\fenics":/home/fenics quay.io/fenicsproject/stable:latest
docker: invalid reference format.
See 'docker run --help'.

Same goes for that one.

Concerning your first hint, the basic docker run command takes the following format (see Docker run reference | Docker Documentation):

$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]

[OPTIONS]-ti and -v

IMAGE[:TAG|@DIGEST] is the container including all sorts of executables like the fenics/dolfin libraries?! In my example IMAGE would then be quay.io/fenicsproject/stable:latest (do not know what is meant by TAG and DIGEST)?

[COMMAND] → ?

[ARG...] → my local directory ?

Just to lift the fog on what is actually going on.

Edit: The following was example 2/4 of the previous post with adding http://quay.io/fenicsproject/stable:latest at the end. This does not create an error instantly but it seems to do the same like the example script:

PS C:\Users\neuma> docker run --rm -it -v C:\Users\neuma\fenics\hybrid-fem-nn-examples-main\examples\pinn_linear\main.py 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@7d49effa0788:~$ cd C:/Users/neuma/fenics/hybrid-fem-nn-examples-main/examples/pinn_linear
bash: cd: C:/Users/neuma/fenics/hybrid-fem-nn-examples-main/examples/pinn_linear: No such file or directory
fenics@7d49effa0788:~$ main.py
bash: main.py: command not found

Again I can’t navigate to the directory of interest or run the code.

That’s wild. Just to double check, docker run -ti quay.io/fenicsproject/stable:latest does work?

Afaik you can’t mount a single file via -v. Further, inside your container you have to use linux commands. That is, show the current files with ls, change directories with cd and specifiy paths via /this/scheme/, and not windows-like (with C:\...)

double check:

PS C:\Users\neuma> docker run -ti 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@3872e8ecbbd2:~$

I would be also ok with mounting a directory which contains python scripts and which I can execute via power shell and plot via browser (or whatever). I’ve tried to follow the linux syntax but couldn’t change to any local directory.

Ok, so from the double check I assume that there is some problem with the mounting of the directories. I’m really just guessing right now, but could you maybe try out
docker run -ti -v "C:\\Users\\neuma\\fenics":/home/fenics quay.io/fenicsproject/stable:latest
that is, with double backslashes?

And if that doesn’t work, could you please create an empty directory (e.g. C:\Users\neuma\fenics\testdir) and try it again with this directory? Once with normal backslashes, once with double backslashes?

Again, if you want to change a directory on linux, you have to use the linux syntax. cd /home, for examples, changes in to the folder /home. With cd .. you go up. There is no C:\whatever on linux. The filesystem root starts with /.

PS C:\Users\neuma> docker run -ti -v "C:\\Users\\neuma\\fenics":/home/fenics quay.io/fenicsproject/stable:latest
docker: invalid reference format.
See 'docker run --help'.
PS C:\Users\neuma> docker run -ti -v "C:\\Users\\neuma\\fenics\\testdir":/home/fenics quay.io/fenicsproject/stable:latest
docker: invalid reference format.
See 'docker run --help'.
PS C:\Users\neuma> docker run -ti -v "C:\Users\neuma\fenics\testdir":/home/fenics quay.io/fenicsproject/stable:latest
docker: invalid reference format.
See 'docker run --help'.

Ok got it. So what is the counterpart to my actual system directory structure on windows when I’m working on the Linux distribution via docker? Say I have a file C:\Users\neuma\fenics\script.py, where would it live in the Linux world of /home/whatever/whatever?

Thank’s btw for all the help!

Hmm, just to make sure: Have you tried it without the quotation marks?
docker run -ti -v C:\Users\neuma\fenics\testdir:/home/fenics quay.io/fenicsproject/stable:latest
Maybe start with this one and if it doesn’t work, try with double backslashes and then without testdir?^^

The Linux file system structure differs fundamentally from Windows. On Windows, if you have for example three devices/partitions, each of them gets a letter and has its own root (C:\..., D:\..., E:\...).
On Linux, however, one ‘abstract’ virtual root is created (/) and the devices are mounted into whatever directory you want them to be mounted. For example, you could decide to mount your first hard drive to /home, your second to /usr and your third to /opt/games/saves.
In general, your home directory would be located at /home/neuma if you were using a Linux system. In docker, however, there is no directory for you or your user account. In the fenics-container, there is only /home/fenics, which is also the location where you ‘spawn’ when you start the container. It is marked by the little ~. You can go up via cd .. and the tilde should be replaced by /home. Then, typing ls should list the only directory, fenics.

No problem, mate.

1 Like

Ok that’s the three runs without quotation marks:

PS C:\Users\neuma> docker run -ti -v C:\\Users\\neuma\\fenics:/home/fenics quay.io/fenicsproject/stable:latest
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

fenics@eb77502101a4:~$ exit
exit

PS C:\Users\neuma> docker run -ti -v C:\\Users\\neuma\\fenics\\testdir:/home/fenics quay.io/fenicsproject/stable:lates
Unable to find image 'quay.io/fenicsproject/stable:lates' locally
docker: Error response from daemon: manifest for quay.io/fenicsproject/stable:lates not found: manifest unknown: manifest unknown.
See 'docker run --help'.

PS C:\Users\neuma> docker run -ti -v C:\Users\neuma\fenics\testdir:/home/fenics quay.io/fenicsproject/stable:latest
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Number one and two seem to ‘work’. If I do ls after the last try I get only the folder shared:

fenics@15c70481b35a:~$ ls
shared

Still the big question: How can I run and see my own scripts? Is there maybe a way just to write python code in the power shell?

That’s good! Ok, could you now please just run of them (preferably the working version with testdir), and then keep the shell opened? That is, don’t type exit, just let it run. While the shell with docker is running, could you check the C:\Users\neuma\fenics\testdir-directory on your Windows system (via file explorer) if any new files appeared?

One additional question, out of curiosity (and because it’s maybe a little bit easier), does this one work?
docker run -ti -v C:/Users/neuma/fenics/testdir:/home/fenics quay.io/fenicsproject/stable:latest

Yup, a shared-folder appeared in the C:\Users\neuma\fenics\testdir.

And yes, docker run -ti -v C:/Users/neuma/fenics/testdir:/home/fenics quay.io/fenicsproject/stable:latest does work.

After exiting a .bash_history-file was created in C:\Users\neuma\fenics\testdir.

Awesome. I recommend using regular slashes from now on, that should avoid the complications with the single/double backslashes.

Now you’re basically done. You can copy every python-script you want into C:/Users/neuma/fenics/testdir on Windows and it should also appear in your docker container. Then, you should be able to run the scripts inside docker (python3 my_script.py, etc.).

dolfinx is not the same as fenicsx but part of it. Fenics contains dolfin this is the original version sometimes referred to as legacy.

The pip package doesn’t look like it’s been updated since 2019 so I think if your start now you are better working with the maintained version.

When you run with docker you are inside the docker container. So things working within the docker don’t necessarily mean you have a successful dolfinx installation.

Use the lab version of the docker launch and share your directory. You should then be able to do most things you want from within jupyter lab.

docker run --init -p 8888:8888 -v "$(pwd)":/root/shared dolfinx/lab:shared

Hi Oskar, try putting this in terminal:

unset PYTHONPATH; unset PETSC_DIR; unset PETSC_ARCH;

then you can run your code:
python3 demo_poisson.py

PS C:\Users\neuma> docker run --init -p 8888:8888 -v "$(pwd)":/root/shared dolfinx/lab:shared
docker: invalid reference format.
See 'docker run --help'.

Great, so with

PS C:\Users\neuma> docker run -ti -v C:/Users/neuma/fenics/testdir:/home/fenics quay.io/fenicsproject/stable:latest
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

fenics@4ca79c045140:~$ ls
hybrid-fem-nn-examples-main  shared
fenics@4ca79c045140:~$ cd ~/hybrid-fem-nn-examples-main/examples/pinn_linear
fenics@4ca79c045140:~/hybrid-fem-nn-examples-main/examples/pinn_linear$ python3 main.py
Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from fenics_adjoint import *
ModuleNotFoundError: No module named 'fenics_adjoint'

I can at least run my own scripts now.

Thank’s for that!

if I remember correctly, $(pwd) seems not to work, right? You could try out ${pwd} in PowerShell, though, if you not already have. I just don’t see the point, since your container is already running.
But in any case, dolfinx/fenicsx is not what you want, since the code you are trying to get running uses legacy fenics. So stick with the quay.io/fenicsproject/stable:latest-image for now.

However, what you can and should do next is to try the port-opening via -p 8888:8888, that is
docker run -ti -p 8888:8888 -v C:/Users/neuma/fenics/testdir:/home/fenics quay.io/fenicsproject/stable:latest

Looks like you need fenics_adjoint (Captain Obvious flies off). According to their page you could maybe try their image? quay.io/dolfinadjoint/pyadjoint:2019.1.0. The other commands should stay the same.

Solved that one by installing directly from the according git-repository using

pip install --user git+https://github.com/sebastkm/hybrid-fem-nn.git@master

(after pip install git+https://github.com/sebastkm/hybrid-fem-nn.git@master didn’t work and the error told me to insert --user (again don’t know why and what it means but it worked))

Works fine, but again I have to foolishly admit that I’m not quite sure what I can expect from this. Is that the way to send plots to an URL to see my results instantly? If yes, will the plots be visible at something like http://host.docker.internal:8888/ (in accordance to Explore networking features on Docker Desktop | Docker Docs)?