最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to run an electron app on docker - Stack Overflow

programmeradmin2浏览0评论

I've created a fork of a repository hosting an electron app which is a chat client: .

What I'm trying to do is to create a docker container with a GUI hooked to the own screen like at / .

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"]

The start.sh file goes like:

./node_modules/.bin/electron ./src

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

I get the error code:

standard_init_linux.go:175: exec user process caused "exec format error"

although I made the file executable and used the right amd64 architecture.

Has anyone figured it out how to make electron GUI's naitively over docker work?

I've created a fork of a repository hosting an electron app which is a chat client: https://github.com/Serkan-devel/BetterDiscordApp-docker.

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/ .

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"]

The start.sh file goes like:

./node_modules/.bin/electron ./src

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

I get the error code:

standard_init_linux.go:175: exec user process caused "exec format error"

although I made the file executable and used the right amd64 architecture.

Has anyone figured it out how to make electron GUI's naitively over docker work?

Share Improve this question edited Oct 8, 2016 at 8:39 jonrsharpe 122k30 gold badges266 silver badges473 bronze badges asked Oct 8, 2016 at 8:14 Patently PaulPatently Paul 3971 gold badge3 silver badges15 bronze badges 7
  • this is your start.sh or you just copy and paste the problematic line? because maybe you are missing #!/bin/sh - first line in shell script – VladoDemcak Commented Oct 8, 2016 at 8:34
  • Then I get /node_modules/electron/dist/electron: error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory – Patently Paul Commented Oct 8, 2016 at 8:46
  • On which OS are you building this image? – VladoDemcak Commented Oct 8, 2016 at 8:50
  • It's lubuntu 16.04 – Patently Paul Commented Oct 8, 2016 at 9:18
  • try apt-get install libgtk2.0-0 or run start.sh with root user – VladoDemcak Commented Oct 8, 2016 at 10:21
 |  Show 2 more comments

2 Answers 2

Reset to default 8

I will try to help you here in this answer - too long for comment.

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"]

and here is your start.sh

#!/bin/sh
./node_modules/.bin/electron ./src

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.

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 .

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

I've found this question useful, finally I've came up with this article to make it even easier:

https://medium.com/@calbertts/developing-electron-apps-in-macos-afd21b4a59e3#.avdge04d6

Hope, you find it useful too.

发布评论

评论列表(0)

  1. 暂无评论