# Deployment with Docker?

**URL:** https://openmc.discourse.group/t/deployment-with-docker/1277
**Category:** User Support
**Created:** [June 26, 2021, 7:09pm UTC](https://openmc.discourse.group/t/deployment-with-docker/1277 "2021-06-26T19:09:45Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![LukeLabrie](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@LukeLabrie](https://openmc.discourse.group/u/LukeLabrie)
#### Post date: [June 26, 2021, 7:09pm UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/1 "2021-06-26T19:09:45Z")

</div>

I am starting an internship soon where I will need to become familiar with OpenMC, and I have been reviewing the documentation and would like to try some examples on my system. I am using a Windows system, so I am trying to use OpenMC with docker. I was able to follow the steps in the Devloper’s Guide ([7. Deployment with Docker — OpenMC Documentation](https://docs.openmc.org/en/stable/devguide/docker.html)), and I am now here: “ **This command will open an interactive shell running from within the Docker container where you have access to use OpenMC.** ”. – I have this shell running, but I don’t understand how to proceed from here to run my own Python script. An ls command shows me this:

_root@86c2a48d914b:/# ls_  
_bin dev home lib32 libx32 mnt proc run srv tmp var_  
_boot etc lib lib64 media opt root sbin sys usr_

How do I run some python code that I’ve written using OpenMC now?

Thank you very much for your time.

---

<div class="post-metadata">

### Author: ![Pranto](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pranto/32/489_2.png) [@Pranto](https://openmc.discourse.group/u/Pranto)
#### Post date: [June 27, 2021, 8:32am UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/2 "2021-06-27T08:32:47Z")

</div>

@LukeLabrie Run your docker image with an interactive bash session.

```auto
docker run -it <image> /bin/bash

```

You can run your python code using the `python file_name.py` command.

Hope this will help!

---

<div class="post-metadata">

### Author: ![LukeLabrie](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@LukeLabrie](https://openmc.discourse.group/u/LukeLabrie)
#### Post date: [June 27, 2021, 3:23pm UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/3 "2021-06-27T15:23:38Z")

</div>

Hi Pranto,

When I run that command, instead of seeing “C:\Users\Luke\>”, it changes to “root@0e5215463fdf:/#”, which I assume means that the image is running. But now the python file\_name.py command does not work. It seems like the image doesn’t have access to these files. Am I missing something?

Thanks for your help.

---

<div class="post-metadata">

### Author: ![Pranto](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pranto/32/489_2.png) [@Pranto](https://openmc.discourse.group/u/Pranto)
#### Post date: [June 27, 2021, 6:02pm UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/4 "2021-06-27T18:02:53Z")

</div>

> [@LukeLabrie](#):
>
> But now the python file\_name.py command does not work.

@LukeLabrie You have to change to the directory where your input file is located.

Ok, Let’s try to run a pincell problem.

```auto
$ cd /opt/ && mkdir test_run && cd /opt/test_run
$ cp ../openmc/examples/pincell/build_xml.py .
$ python build_xml.py
$ openmc

```

Best  
pranto

---

<div class="post-metadata">

### Author: ![LukeLabrie](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@LukeLabrie](https://openmc.discourse.group/u/LukeLabrie)
#### Post date: [June 27, 2021, 6:09pm UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/5 "2021-06-27T18:09:22Z")

</div>

Ok, do you mind explaining what that first command is doing? I looked up the cp command on Docker and it says you need to specify a source and destination. The source I imagine would be my local pin\_cell.py file, but how do I specify a destination on the image that I’m going to run in docker?

---

<div class="post-metadata">

### Author: ![Pranto](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pranto/32/489_2.png) [@Pranto](https://openmc.discourse.group/u/Pranto)
#### Post date: [June 27, 2021, 6:56pm UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/6 "2021-06-27T18:56:25Z")

</div>

`&&` is used for chain commands such that the next command is run if and only if the preceding command exits without error. You can run each command separately

```bash
$ cd /opt/
$ mkdir test_run
$ cd /opt/test_run

```

> [@LukeLabrie](#):
>
> but how do I specify a destination on the image that I’m going to run in docker?

To refer the destination you can use a dot `(.)` means copy the file in my current working directory.

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [June 28, 2021, 3:44am UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/7 "2021-06-28T03:44:37Z")

</div>

@LukeLabrie It sounds like you want to access files on your Windows drive from the docker container. If so, see [this question](https://stackoverflow.com/questions/45267457/access-file-of-windows-machine-from-docker-container) on stackoverflow.

---

<div class="post-metadata">

### Author: ![LukeLabrie](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@LukeLabrie](https://openmc.discourse.group/u/LukeLabrie)
#### Post date: [June 28, 2021, 9:34pm UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/8 "2021-06-28T21:34:25Z")

</div>

Paul, when I use the volume mount discussed in that post I do see my file in the docker container, but I am still unable to run it. See below:

Running the docker image:  
`docker run -it --name=my_openmc --rm -v /pin_cell.py debian/openmc:latest`

ls command:

```auto
root@39c7893610d3:/# ls
bin dev home lib32 libx32 mnt pin_cell.py root sbin sys usr
boot etc lib lib64 media opt proc run srv tmp var

```

As you can see, the file is there. Now I try to run the file:

```auto
root@39c7893610d3:/# python pin_cell.py
/usr/bin/python: can't find ' __main__' module in 'pin_cell.py'

```

So I think I’m one step closer here, but still missing something. Any ideas?

---

<div class="post-metadata">

### Author: ![LukeLabrie](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@LukeLabrie](https://openmc.discourse.group/u/LukeLabrie)
#### Post date: [June 29, 2021, 1:20am UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/9 "2021-06-29T01:20:43Z")

</div>

Figured it out!

The key is to use an absolute filepath instead of a relative file path, i.e.

`docker run -it --name=my_openmc1 --rm -v $pwd/pin_cell.py:/containerdir debian/openmc:latest`

Instead of:

`docker run -it --name=my_openmc1 --rm -v /pin_cell.py:/containerdir debian/openmc:latest`

Thank you pranto and thank you Paul for your time and guidance.

Luke

---

<div class="post-metadata">

### Author: ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)
#### Post date: [August 15, 2021, 2:11am UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/10 "2021-08-15T02:11:58Z")

</div>

Another option for running files within the Docker container is to install VScode on windows along with the Remote Contain addition. This provides a terminal and a IDE that inherits from the container.

> **[Download Visual Studio Code - Mac, Linux, Windows](https://code.visualstudio.com/download)**
>
> Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications.

[![](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/3/38c1a0b5ad3b74eb8d677f0204871ae083cc26a4.jpeg "Visual Studio Code Development Containers: A Guide for Students") ](https://www.youtube.com/watch?v=Uvf2FVS1F8k)

---

<div class="post-metadata">

### Author: ![Nilormi](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@Nilormi](https://openmc.discourse.group/u/Nilormi)
#### Post date: [March 24, 2023, 10:13am UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/11 "2023-03-24T10:13:09Z")

</div>

Could you please kindly elaborate the steps? I am using OpenMC for my project. I have no one to guide except this forum.

I have installed Docker container, Visual Studio, Git, Dev Container extension, and Python. How do I execute? Is it possible for you to have a meeting with you so that I can share my screen and you can kindly guide me?

---

<div class="post-metadata">

### Author: ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)
#### Post date: [March 24, 2023, 7:59pm UTC](https://openmc.discourse.group/t/deployment-with-docker/1277/12 "2023-03-24T19:59:14Z")

</div>

We have a monthly meeting soon, feel free to attend

> [@OpenMC monthly meeting dates 2023](https://openmc.discourse.group/t/openmc-monthly-meeting-dates-2023/2651/4):
>
> I was unable to log in too, is there a session recording?
