Using VNCserver + GUI application + Virtual Display in Docker container
2017-07-19 21:56
411 查看
https://stackoverflow.com/questions/36221215/using-vncserver-gui-application-virtual-display-in-docker-container
I would like to run firefox (or any graphical application) inside docker container.
My requirement: When I start the container, I should be creating a virtual display, starting VNC server and then the GUI application. This means after the container is successfully started, I can connect to the GUI application running inside
the container via VNC client. When I close the application, the container should automatically stop.
Attempt 1:I started with the example here https://hub.docker.com/r/devopsil/vnc-firefox/~/dockerfile/In this example the developer starts the vnc server via CMD and keeps it running forever. He puts the firefox as part of .rc file so it starts when the container starts. If you connect via VNC client,
you can see firefox and as expected closing firefox or disconnecting the VNC session does not stop the container.
Attempt 2:I tuned the Dockerfile as follows. Changed only the last line (replaced CMD with ENTRYPOINT and removed the “forever” flag”)
Rebuilding and running the container “docker run --rm -p 5900 ” had a different behaviour now:container starts, connection via VNC client worked, firefox opened after a few seconds (wait after the message "extension RANDR missing on display :20") and the
container stopped automatically after closing the vnc connection.
Attempt 3:Then I created a bash script to start the vncserver and firefox and changed the Dockerfile to copy this script file inside the image and made the script as the entry point. But I got the error similar to “Display variable not set”
Attempt 4:So I passed the DISPLAY variable via the docker run command but then the error is cannot open display.
Question: I don’t know how to like the virtual display created by the vncserver flag “-create” to the firefox. Please let me know what would be best way to start the GUI application when the container starts and automatically stop the container
when the GUI application is closed. I believe the ENTRYPOINT in dockerfile should be set to firefox. Thanks for your help.
I have seen this https://blog.jessfraz.com/post/docker-containers-on-the-desktop/ but this is of no use to me as I want to access the application remotely via VNC.
===================================================================
Changed the script in Attempt 3 above as follows worked
Cheers.
Maybe we can run
I would like to run firefox (or any graphical application) inside docker container.
My requirement: When I start the container, I should be creating a virtual display, starting VNC server and then the GUI application. This means after the container is successfully started, I can connect to the GUI application running inside
the container via VNC client. When I close the application, the container should automatically stop.
Attempt 1:I started with the example here https://hub.docker.com/r/devopsil/vnc-firefox/~/dockerfile/In this example the developer starts the vnc server via CMD and keeps it running forever. He puts the firefox as part of .rc file so it starts when the container starts. If you connect via VNC client,
you can see firefox and as expected closing firefox or disconnecting the VNC session does not stop the container.
Attempt 2:I tuned the Dockerfile as follows. Changed only the last line (replaced CMD with ENTRYPOINT and removed the “forever” flag”)
ENTRYPOINT ["/usr/bin/x11vnc", "-usepw", "-create"]
Rebuilding and running the container “docker run --rm -p 5900 ” had a different behaviour now:container starts, connection via VNC client worked, firefox opened after a few seconds (wait after the message "extension RANDR missing on display :20") and the
container stopped automatically after closing the vnc connection.
Attempt 3:Then I created a bash script to start the vncserver and firefox and changed the Dockerfile to copy this script file inside the image and made the script as the entry point. But I got the error similar to “Display variable not set”
#!/bin/bash /usr/bin/x11vnc -forever -usepw -create & firefox
Attempt 4:So I passed the DISPLAY variable via the docker run command but then the error is cannot open display.
Question: I don’t know how to like the virtual display created by the vncserver flag “-create” to the firefox. Please let me know what would be best way to start the GUI application when the container starts and automatically stop the container
when the GUI application is closed. I believe the ENTRYPOINT in dockerfile should be set to firefox. Thanks for your help.
I have seen this https://blog.jessfraz.com/post/docker-containers-on-the-desktop/ but this is of no use to me as I want to access the application remotely via VNC.
===================================================================
Answer
I managed to found the solution:Changed the script in Attempt 3 above as follows worked
!/bin/bash Xvfb :1 -screen 0 800x600x16 & /usr/bin/x11vnc -display :1.0 -usepw & DISPLAY=:1.0 export DISPLAY firefox
Cheers.
Maybe we can run
/usr/bin/x11vnc -display :1.0 -usepw -forever &
相关文章推荐
- TABSCRIP 两种类型 scrolling in the application server和scrolling in sapgui的区别
- VNC Server in Virtual Mode does not start correctly on Ubuntu 12.04
- Using Couchbase Server In A GoLang Web Application
- Using TurboVNC 0.6 and VirtualGL 2.1.4 to run OpenGL Application Remotely on CentOS
- Start hadoop, hive, hue server in the virtual hadoop clusters based on docker
- Start hadoop, hive, hue server in the virtual hadoop clusters based on docker
- Setting VirtualBox to use it's built-in VNC server (ver. >= 4.2 I think) - failed
- File operations in SAP Application server (AL11) using UNIX Command
- (全英文)How to install and run a simple Asp.Net 5 Application in a Docker Container
- Creating a ControlBar container in Flex using ActionScript
- the virtual machine is in use by an application on your host computer
- Using Java Classes in your .NET Application -摘自网络
- Using the TIME data type in SQL Server 2008
- A guide to using Paneled Forms, Multi-Splash Screens, SQL Express, and many more in Windows Application Development
- How to "enalbe mouse integration" and make screen display fully in Oracle VM VirtualBox in Ubuntu
- translation:Achieving of Chinese Display in the embedded graphical user interface of uC/GUI in Two
- using sql server or sql azure for session state store in asp.net
- Using the Microsoft Access Providers to Replace the Built-In SQL Server Providers
- How do I configure vncserver to start GNOME or KDE by default in Red Hat Enterprise Linux ?
- Docker - How to Connect to a MySQL Running Container Using MySQL Command Line Client