0

Docker for Windows.

I've written a docker image for a python project.
When I start a container based on this image, one of the instructions that gets executed is the following:

os.system(f"start \"\" "path/to/pdf_file.pdf")

which simply opens the specified PDF file with the default PDF opener.

This instruction works perfectly locally, but, if I run it from a docker container, this file doesn't get opened in my local machine.
This makes sense, it probably gets opened in the docker container, and I can't see it because I've no way of seeing what's going on in the container (except by looking at the container logs).

My goal is to have the docker container TELL to my local machine to execute that command, in such a way the PDF file gets opened in my local machine, not in the docker container.

How could I achieve such goal?

chattershuts
  • 366
  • 2
  • 10
  • 1
    If this was possible, that would simply defeat the purpose of containerization and isolation, – Zeitounator Jan 09 '23 at 17:45
  • Agree on that, but I don't know how else I could open a PDF file from a docker image unfortunately – chattershuts Jan 09 '23 at 17:49
  • Among the multiple solutions we could imagine: add a webserver to your image and open the file on your local machine from url.... – Zeitounator Jan 09 '23 at 18:18
  • By design you can't do this. You might look at [How to run shell script on host from docker container?](https://stackoverflow.com/questions/32163955/how-to-run-shell-script-on-host-from-docker-container) which has several quite involved Linux-specific approaches to this. So something similar might be possible on Windows, but it will almost certainly be more complex than just running the program in a host-based non-container Python environment. – David Maze Jan 09 '23 at 19:32

0 Answers0