sid5432 / pyOTDR

Simple OTDR SOR file parser written in Python
GNU General Public License v3.0
71 stars 28 forks source link

can't export the data from docker image #31

Closed philippengani closed 3 years ago

philippengani commented 3 years ago

I was able to download the docker image available for this library. Unfortunately the seems to be no way for me to extract the output of the command to my host computer. Any solution for this??

sid5432 commented 3 years ago

The latest docker image (from Docker Hub) has some problems. As it is right now, if you have downloaded the image, you can run something like this:

docker run -ti --rm -v /my/folder:/data sidneyli/pyotdr:latest /data/myOTDRfile.sor

where the "myOTDRfile.sor" file has to be in /my/folder on the host computer (i.e, we map /my/folder/myOTDRfile.sor on the host computer to /data/myOTDRfile.sor inside the container). When you run this, you will see the extracted/summary information show up on STDOUT (on your screen).

What is happening here has to do with the entry point to the docker image. If you look at the Dockerfile for building pyOTDR, the entry point is "pyOTDR". This takes the first argument (in this case, /data/myOTDRfile.sor) and runs the pyOTDR command with it. In other words, in the container, it is running

pyOTDR /data/myOTDRfile.sor

The problems is that the pyOTDR command is not running in the /data/ folder, so the files that it spits out is not in that folder, and becomes inaccessible from outside the container. Even if you remove the "--rm" flag to force the container to stay around, you still can't "login" to the container once it is set up (the entry point blocks you from doing that).

So if you really need the JSON and trace data files, what can you do? The work-around is to bypass the entry point, and run the docker container like this:

docker run -ti --entrypoint /bin/bash -v /my/folder:/data sidneyli/pyotdr:latest

What happens now is that you get a command prompt inside the container. You can now navigate to the /data folder inside the container (which maps to the /my/folder directory on the host computer) and run the pyOTDR command from there.

This is a rather ugly solution, and I think the entry point in the Dockerfile should really be changed to /bin/bash. But that's for another time.