Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Python File Input Selector

I'm trying to configure a Docker image so that a user can type in "docker run image" and have a window pop up to select the input file. I tried to use Tkinter when creating the Docker image, but the Python script errors out when it tries to load Tkinter.

Since Tkinter did not work I tried to just switch to a normal input query using:

path= input('Input the file path:\n')

But now I am getting an "EOFError: EOF when reading a line" when it gets to the input() line.

My Dockerfile is as follows

FROM python:3
ADD script.py /
RUN pip install xlrd
RUN pip install numpy
RUN pip install matplotlib
CMD [ "python", "./script.py" ]

Any ideas as to why this is happening? I'm very new to using Docker so any help would be much appreciated :)

like image 773
DLee Avatar asked May 26 '17 21:05

DLee


1 Answers

You need to run the container with docker run -ti image to make sure that it runs in interactive mode with the terminal attached.

Running X11 GUI applications is a bit more tricky since you need to give the container access to your display. This blog post describes the process in more details.

like image 79
Adam Byrtek Avatar answered Nov 15 '22 03:11

Adam Byrtek