How do I display output in a simple Python docked application?
I just started using docker and I am still struggling a little with it. I have a simple python python application that uses Matplotlib to generate some simple plots. I currently have the following Dockerfile:
FROM python:2
COPY requirements.txt /
RUN pip install --requirement requirements.txt
COPY my_code.py /
CMD [ "python", "./my_code.py" ]
However, this generates the following error:
Traceback (most recent call last):
File "./fraud_detection_sample_code.py", line 161, in <module>
plt.figure(1)
File "/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 535, in figure
**kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 81, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 89, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 1820, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
What would be the best way to solve this problem? Is this possible with my approach?
+3
source to share