具有X11转发的Docker中的电子 - 未指定协议

时间:2017-03-20 23:30:09

标签: docker electron

我正在尝试使用X11转发在Docker容器中运行Electron Quick Start。我已经找到了所有合适的包,但是当我运行容器时,我得到了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"]

构建并运行

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应用的正确方法是什么?

1 个答案:

答案 0 :(得分:8)

在主机中运行xhost local:root,然后尝试运行容器以运行电子