# PyIGTL in Docker: Trouble with 

**URL:** <https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447>\
**Category:** Support\
**Created:** [September 11, 2025, 2:11pm UTC](https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447 "2025-09-11T14:11:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oskey999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/oskey999/32/81011_2.png) [@Oskey999](https://discourse.slicer.org/u/Oskey999)\
**Post date:** [September 11, 2025, 2:11pm UTC](https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447/1 "2025-09-11T14:11:00Z")

</div>

Hello, would this be the right place to post this?

I am trying to run a python script that communicates with a 3d slicer extension using the pyigtl library.

However, I am struggling to get the script to communicate with slicer. which is outside the container.

The docker Image is the _python:3.10-slim-bullseye_, but the same errors occur with the _nvidia/cuda:12.3.0-base-ubuntu22.04 image._

Basically, the script runs :

```python
text_server = pyigtl.OpenIGTLinkServer(port=18945, local_server=True)

```

the code will stall on the next part:

```python
string_message = pyigtl.StringMessage(f, device_name="TextMessage")
text_server.send_message(string_message)

```

Attempting to set local server to false like so:

```python
text_server = pyigtl.OpenIGTLinkServer(port=18945, local_server=False, iface="0.0.0.0".encode('utf-8'))

```

reuslts in this error:

```bash
Traceback (most recent call last):
  File "/app/server/server.py", line 174, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
  File "/app/server/server.py", line 170, in main
    await tmsserver.run_server()
  File "/app/server/server.py", line 43, in run_server
    servertms = pyigtl.OpenIGTLinkServer(port=18944, local_server=False, iface="0.0.0.0".encode('utf-8'))
  File "/usr/local/lib/python3.10/dist-packages/pyigtl/comm.py", line 178, in __init__
    self.host = socket.inet_ntoa(fcntl.ioctl(soc.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24])
struct.error: argument for 's' must be a bytes object

```

the same error occurs if the iface var is set to wifi0 and wlan0 and eth0 stalls like the local version

For added context the script is SlicerTMS/server/server.py in the [SlicerTMS](https://github.com/lorifranke/SlicerTMS.git) github page

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 11, 2025, 2:13pm UTC](https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447/2 "2025-09-11T14:13:15Z")

</div>

Maybe it’s as simple as making sure the port is mapped from the docker instance?

---

<div class="post-metadata">

**Author:** ![Oskey999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/oskey999/32/81011_2.png) [@Oskey999](https://discourse.slicer.org/u/Oskey999)\
**Post date:** [September 11, 2025, 2:51pm UTC](https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447/3 "2025-09-11T14:51:50Z")

</div>

> [@pieper](#):
>
> making sure the port is m

I run the docker containers with  
``` bash`  
`docker run -it -p 18944:18944 -p 18945:18945 test`  
```

and expose both ports in the docker file with

```auto
EXPOSE 18944
EXPOSE 18945

```

but that does not change the errors I am experiencing

was there anything I need to do for port mapping?

would it help if I changed the ports used by the python script?

Thanks

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 11, 2025, 3:13pm UTC](https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447/4 "2025-09-11T15:13:37Z")

</div>

I suggest getting the communication working with pyigtl outside of docker with simple test cases and then try those test cases inside docker to debug.

---

<div class="post-metadata">

**Author:** ![Oskey999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/oskey999/32/81011_2.png) [@Oskey999](https://discourse.slicer.org/u/Oskey999)\
**Post date:** [September 12, 2025, 1:40am UTC](https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447/5 "2025-09-12T01:40:25Z")

</div>

> [@Oskey999](#):
>
> 18945

I have been able to get the same script running in a dev environment on my windows 11 PC,

doing that it connects fine and doesn’t cause any problems.

Otherwise, I will looking into getting simpler test cases running, likely sometime next week

Thanks

---

<div class="post-metadata">

**Author:** ![Oskey999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/oskey999/32/81011_2.png) [@Oskey999](https://discourse.slicer.org/u/Oskey999)\
**Post date:** [September 15, 2025, 2:20am UTC](https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447/6 "2025-09-15T02:20:56Z")

</div>

Also, forgot to mention a weird bit, I got 3d slicer and the python script to run in the same container and had the same issue

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 15, 2025, 5:25am UTC](https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447/7 "2025-09-15T05:25:06Z")

</div>

We used OpenIGTLink between Slicer instances in linux docker containers and it worked well.

> [@Oskey999](#):
>
> the code will stall on the next part:
> 
> ```auto
> string_message = pyigtl.StringMessage(f, device_name="TextMessage")
> text_server.send_message(string_message)
> 
> ```

This is supposed to stall until a client is connected. You can attach a debugger to confirm that indeed the server is waiting on a client to connect.

Do you run pyigtl in Slicer application’s Python environment or in a different Python executable?  
In Slicer, you need to use the OpenIGTLinkIF module instead of pyigtl.

---

<div class="post-metadata">

**Author:** ![Oskey999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/oskey999/32/81011_2.png) [@Oskey999](https://discourse.slicer.org/u/Oskey999)\
**Post date:** [September 19, 2025, 2:28am UTC](https://discourse.slicer.org/t/pyigtl-in-docker-trouble-with/44447/8 "2025-09-19T02:28:39Z")

</div>

> [@lassoan](#):
>
> module

HI, Thanks for all the help.

It works now, after uninstalling and reinstalling the OpenIGTLinkIF extension, I could connect using

```python
text_server = pyigtl.OpenIGTLinkServer(port=18945, local_server=False, iface="eth0".encode('utf-8'))
string_message = pyigtl.StringMessage(f, device_name="TextMessage")
text_server.send_message(string_message)

```

I don’t really know what changed when it was reinstalled but it now showed this connection when on the OpenIGTLinkIF menu.

As for the development environment from before, it was a separate environment to the one associated with the slicer application.
