Reputation: 364
First day trying to 'Dockerize' my Python GUI made in Tkinter for the purpose of having it as a standalone application and nothing is displayed despite using a recommended command to do so: run -it -e DISPLAY=$DISPLAY background-revolution
(with it supposedly being interactive mode and -e to set the display as the user's own) Here is the Dockerfile:
FROM python:3.9
ADD main.py .
RUN pip install pillow
CMD ["python", "./main.py"]
The output it gives me is a test print statement I wrote that says "docker working" but none of the actual GUI (which works fine from running it normally). To build the Docker image this is what I ran: docker build -t background-revolution .
[+] Building 10.5s (9/9) FINISHED
=> [internal] load build definition from Dockerfile 0.2s
=> => transferring dockerfile: 133B 0.0s
=> [internal] load .dockerignore 0.2s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3.9 0.9s
=> [auth] library/python:pull token for registry-1.docker.io 0.0s
=> CACHED [1/3] FROM docker.io/library/python:3.9@sha256:acb4e43d0c66c168e72ceaba5913cde472e4a17017cec9346969c9725a1fea94 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 12.01kB 0.0s
=> [2/3] ADD main.py . 0.5s
=> [3/3] RUN pip install pillow 6.9s
=> exporting to image 1.5s
=> => exporting layers 1.2s
=> => writing image sha256:95e56740a3427899906e9c6522198f5d749fd13870450b046a2bd874b3a04548 0.0s
=> => naming to docker.io/library/background-revolution
Upvotes: 0
Views: 437
Reputation: 171
Docker containers does't allow GUI, there are some workarounds like redirect to you X server on Unix but it's not a good solution.
If you want a standalone python application, you could use pyinstaller link or something similar.
Upvotes: 1