Can't run model in Docker container

Hi all,

When running the following MWE in a container from openmc/openmc:latest, I get the following error:

MWE.py

import openmc

mat = openmc.Material()
mat.add_nuclide('Zr90', 1.0)
mat.set_density('g/cm3', 1.0)

model = openmc.Model()
sph = openmc.Sphere(r=25.0, boundary_type='vacuum')
cell = openmc.Cell(fill=mat, region=-sph)
model.geometry = openmc.Geometry([cell])

model.settings.run_mode = 'fixed source'
model.settings.batches = 2
model.settings.particles = 50

model.run()

To reproduce:

docker run -ti openmc/openmc
cd home
git clone https://github.com/openmc-dev/openmc
cd openmc
pip install -e .
python MWE.py

I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/openmc/openmc/model/model.py", line 553, in run
    if self.is_initialized:
  File "/home/openmc/openmc/model/model.py", line 115, in is_initialized
    import openmc.lib
  File "/home/openmc/openmc/lib/__init__.py", line 32, in <module>
    _dll = CDLL(_filename)
  File "/usr/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /home/openmc/openmc/lib/libopenmc.so: cannot open shared object file: No such file or directory

Is something broken with the openmc docker images?
I’m also surprised I have to clone openmc

Hi Remi, great to see you on here

For some reason the last docker image release didn’t install the python openmc api correctly. This was reported and solved (for the next docker release) in this github issue Openmc docker image missing openmc · Issue #1973 · openmc-dev/openmc (github.com)

I would try running the docker image but cd into the existing openmc dir and pip install from there

docker run -ti openmc/openmc
cd /opt/openmc
pip install -e .

Ok I shall try this.

Any idea how I could use this in development from a fork of the openmc repo?

In that case I would use the Docker image I have in a PR built with a target of dependencies, then run and mount the local openmc repo and work from that.

However using the existing dockerimage you could change the remote url

git remote set-url <remote_name> <remote_url>

Another option is to use GitHub Codespaces which would allow you to launch a dev environment in the browser in the manner you require.