3
我剛剛開始使用docker,並且仍然在使用中苦苦掙扎。我有一個Python簡單的Python應用程序,它使用Matplotlib來生成一些簡單的圖形。目前,我有以下Dockerfile:如何在簡單的dockerized Python應用程序中顯示輸出?
FROM python:2
COPY requirements.txt/
RUN pip install --requirement requirements.txt
COPY my_code.py/
CMD [ "python", "./my_code.py" ]
然而,這產生了以下錯誤:
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
什麼是解決這個的最好方法?我的方法有可能嗎?
Docker並不意味着這種用例。 – Smit
在這種情況下,你會如何對這樣的應用程序進行dockerize?或者它根本不可能? – hY8vVpf3tyR57Xib
問題是,當用戶羣增長時,docker需要在多個VM上部署和擴展您的應用程序。 Dockerizing只是通過命令行顯示輸出的python腳本沒有任何意義。 – Smit