电子在docker与X11转发 – 没有协议指定

我正尝试在X11转发的Docker容器中运行Electron Quick Start。 我已经find了所有合适的软件包,但是当我运行容器时,我得到了No protocol specified 。 我不知道我错过了什么工作。

Dockerfile

 FROM node RUN apt-get update RUN apt-get -y install libgtkextra-dev libgconf2-dev libnss3 libasound2 libxtst-dev libxss1 libx11-xcb-dev WORKDIR /srv ADD . . RUN npm install ENTRYPOINT ["npm", "start"] 

build立和运行

 docker build -t electron . docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY electron 

产量

 npm info it worked if it ends with ok npm info using npm@4.1.2 npm info using node@v7.7.2 npm info lifecycle electron-quick-start@1.0.0~prestart: electron-quick-start@1.0.0 npm info lifecycle electron-quick-start@1.0.0~start: electron-quick-start@1.0.0 > electron-quick-start@1.0.0 start /srv > electron . No protocol specified npm info lifecycle electron-quick-start@1.0.0~start: Failed to exec start script npm ERR! Linux 4.8.0-41-generic npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" npm ERR! node v7.7.2 npm ERR! npm v4.1.2 npm ERR! code ELIFECYCLE npm ERR! electron-quick-start@1.0.0 start: `electron .` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the electron-quick-start@1.0.0 start script 'electron .'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the electron-quick-start package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! electron . npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs electron-quick-start npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls electron-quick-start npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /srv/npm-debug.log 

问:在Docker中运行Electron应用程序的正确方法是什么?


在主机上运行xhost local:root然后尝试运行你的容器来运行电子