問題描述
我創(chuàng)建了一個托管電子應(yīng)用程序的存儲庫的分支,該應(yīng)用程序是一個聊天客戶端:https://github.com/Serkan-devel/BetterDiscordApp-docker.
I've created a fork of a repository hosting an electron app which is a chat client: https://github.com/Serkan-devel/BetterDiscordApp-docker.
我要做的是創(chuàng)建一個 docker 容器,其 GUI 連接到自己的屏幕,例如 https://blog.jessfraz.com/post/docker-containers-on-the-desktop/ .
What I'm trying to do is to create a docker container with a GUI hooked to the own screen like at https://blog.jessfraz.com/post/docker-containers-on-the-desktop/ .
我創(chuàng)建的 dockerfile 如下:
The dockerfile I've created goes like:
FROM node:slim
COPY . /usr/scr/app
#RUN rm bdstart.sh
RUN npm install --save-dev electron
RUN npm install
#ENV FRESHINSTALL=true
CMD ["/usr/scr/app/start.sh"]
start.sh 文件如下:
The start.sh file goes like:
./node_modules/.bin/electron ./src
構(gòu)建 docker 鏡像并使用它執(zhí)行后
After building the docker image and execute it with
docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY --device /dev/snd dixord
我得到錯誤代碼:
standard_init_linux.go:175: exec user process caused "exec format error"
雖然我使文件可執(zhí)行并使用了正確的 amd64 架構(gòu).
although I made the file executable and used the right amd64 architecture.
有沒有人想出如何讓電子圖形用戶界面在 docker 工作上更加天真?
Has anyone figured it out how to make electron GUI's naitively over docker work?
推薦答案
我會盡力在這個答案中幫助你 - 太長了,無法評論.
I will try to help you here in this answer - too long for comment.
我在我的 Win10 上嘗試了你的 Docker 文件,但遇到了同樣的問題.但是我通過添加所需的包并成功創(chuàng)建了 docker 映像來解決這個問題.這里是 Dockerfile
I tried your Docker file on my Win10 and with the same problems. But I figured it out by adding required packages and successfully created docker image. Here is Dockerfile
FROM node:slim
COPY . /usr/scr/app
#RUN rm bdstart.sh
RUN apt-get update
# I think you need to install following
RUN apt-get -y install libgtkextra-dev libgconf2-dev libnss3 libasound2 libxtst-dev libxss1
RUN npm install --save-dev electron
RUN npm install
CMD ["/usr/scr/app/start.sh"]
這是你的 start.sh
#!/bin/sh
./node_modules/.bin/electron ./src
實(shí)際上我無權(quán)訪問您的文件等,但是有了這個 DockerFile 能夠毫無問題地創(chuàng)建 docker 映像.我還進(jìn)入了 docker 容器并檢查是否可以運(yùn)行電子 - 工作.
Actually I don't have access to your files and so on, but with this DockerFile was able to create docker image without problems. I also went inside docker container and check whether is possible to run electron - worked.
如果你想進(jìn)入容器,你只需要構(gòu)建 docker 鏡像.我已經(jīng)通過(最簡單的方式)按照命令(打開控制臺Dockerfile所在的位置并運(yùn)行):
If you want to go into container, you just need to build docker image. I have done it by (simplest way) following command (open console where Dockerfile is located and run):
docker build -t test-image .
成功構(gòu)建鏡像后,您可以運(yùn)行容器.如果有任何問題,我建議您使用 bash
入口點(diǎn)運(yùn)行容器并調(diào)試失敗的內(nèi)容 - bash 將在您鍵入以下腳本的同一控制臺中打開)
After Successfully build of image you can run container. If any problems I recommend you to run container with bash
entrypoint and debug what fails - bash will open in the same console where you type following script)
docker run -it test-image bash
這篇關(guān)于如何在 docker 上運(yùn)行電子應(yīng)用程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!