How to use docker desktop for Windows with VS Code

I created a Docker container from Windows PowerShell for dolphinx with the command available in the Readme.md for dolphinx package. The container is running and I installed a couple of helper extensions for VS Code for using Docker.

My question is that I would like to know how to start a new Python file and have:

from fenics import *
mesh = UnitCube(8,8)

start to pull in all of the dependancies for dolphinx. So far UnitCube is not being found as a function although the example I have states that it should be. VS Code does see some containers and images however I wasn’t able yet to get the two lines of Python source code above to start to work yet.

Anyone know how to get this going either for Windows and/or WSL2 for Ubuntu 22.04 that I also have installed? I was hoping I could get docker to pull into Python the whole fenics module that should contain UnitCube function to run some examples from VS Code.

Can you share those examples? A container is just an isolated environment. If you know how it should work without containers on the same platform, it should work in containers too.

Oh… I mis-spelled that its dolfinx.

docker pull dolfinx/dolfinx:nightly
nightly: Pulling from dolfinx/dolfinx
837dd4791cdc: Pull complete
4f4fb700ef54: Pull complete
d8df748303d7: Pull complete
1a8ba85d7aaf: Pull complete
838412fe8c4a: Pull complete
598c17c023cb: Pull complete
ce3e99eaa9da: Pull complete
de88663c8b8b: Pull complete
1108757fd1c7: Pull complete
2968d9b91306: Pull complete
84a6cc731559: Pull complete
4b817a25c399: Pull complete
fd70142e0747: Pull complete
dfac48b590ff: Pull complete
Digest: sha256:03f62e3b1781e60932dbd64211cc8bc967495976ffbbe7b7b14d13f1e70d6344
Status: Downloaded newer image for dolfinx/dolfinx:nightly
docker.io/dolfinx/dolfinx:nightly

I chose WSL option when installing on Windows. I noticed so far after that pull I have.

wsl --list
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
docker-desktop (new)
docker-desktop-data (new)

Ultimately I will need to do two things. First I have to build dolfinx for cpp and python inside the container and have the build and configuration be remembered it. Secondly I would like to have a way to connect VS Code from windows desktop into the container to code projects inside the container.

Anyone can help me?!

Someplace I got the notion I have to name the container somehow? Really perplexed so far first time using Docker.

What are those new WSL’s on --list? why seperate one for data?

So far dolfinx does build and install inside the container cpp and python. I am still having difficulties getting vs code to connect to the container to start a python code example. no ports are stated as available to connect…

Oh…
Developing inside a Container using Visual Studio Code Remote Development

It is stated how to mashup them together. Seems to work alright so far.

My guess is that this way Docker Desktop can be updated more easily, but I never really cared enough to find out the reason

So your issue is solved? I hope, because I didn’t understand all of your questions. For example “naming the container”.

Note: Please, next time format your posts according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

I would call the issue resolved it at this point. There are so many extensions docker for vs code it took a while to find the right one. It seems that in windows docker gui handles naming very well. I’m not sure how things will work for naming on Ubuntu but I suppose if there were any problems cropping up that would be a new issue for linux.