Running GUI apps with Docker
来源:互联网 发布:手机知乎怎么注册 编辑:程序博客网 时间:2024/05/08 15:05
http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
I’ve been doing all of my real (paid) work on VMs / containers for a while now but when it comes to writing Java code for some projects for university I stillneed to move away from using vim and install some full blown IDE in order to beproductive. This has been bothering me for quite some time but this week Iwas finally able put the pieces together to run NetBeans in a Docker container so that I can avoidinstalling a lot of Java stuff on my machine that I don’t use on a daily basis.
There are a few different options to run GUI applications inside a Dockercontainer like usingSSH with X11 forwarding,or VNC but the simplest one that Ifigured out was to share my X11 socket with the container and use it directly.
The idea is pretty simple and you can easily it give a try by running a Firefoxcontainer using the followingDockerfile
as a starting point:
FROM ubuntu:14.04RUN apt-get update && apt-get install -y firefox# Replace 1000 with your user / group idRUN export uid=1000 gid=1000 && \ mkdir -p /home/developer && \ echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \ echo "developer:x:${uid}:" >> /etc/group && \ echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \ chmod 0440 /etc/sudoers.d/developer && \ chown ${uid}:${gid} -R /home/developerUSER developerENV HOME /home/developerCMD /usr/bin/firefox
docker build -t firefox .
it and run the container with:
docker run -ti --rm \ -e DISPLAY=$DISPLAY \ -v /tmp/.X11-unix:/tmp/.X11-unix \ firefox
If all goes well you should see Firefox running from within a Docker container.
Getting a NetBeans container up and running
Preparing a NetBeans base image was not that straightforward since we need toinstall some additional dependencies (namely thelibxext-dev
, libxrender-dev
and libxtst-dev
packages) in order to get it to connect to the X11 socketproperly. I also had trouble using OpenJDK and had to switch to Oracle’s Javafor it to work.
After lots of trial and error, I was finally able to make it work and the resultis a base image available at theDocker Hubwith sources onGitHub.
Here’s a quick demo of it in action:
Future work
Over the next few months I’ll be working on a Play!app and will hopefully write a blog post on the workflow I used. Stay tunned for more :)
PS: This approach of sharing the X11 socket also be applied to vagrant-lxccontainers and I’ll document that on the project’s Wiki when Ihave a chance.
- Running GUI apps with Docker
- Running Android apps using Docker and ARC Welder
- Running quagga docker container with GNS3
- Running ASP.NET 5 applications in Linux Containers with Docker
- Scaling Apps with Varnish
- win32-apps-with-mingw
- Interacting with Other Apps
- Building Apps with Multimedia
- Building Apps with Multimedia
- Integration with Existing Apps #
- Running docker on Android
- ethereum Running in Docker
- Running MARSSx86 with DRAMSim2
- Docker GUI调研
- Docker GUI调研
- Instrumenting Android Apps with Soot
- Building Huuuuuge Apps with AngularJS
- Create Apps with Material Design
- 5-38 数列求和-加强版 (20分)
- ZOJ 3209 Treasure Map(精确覆盖)
- leeetcode 153. Find Minimum in Rotated Sorted Array
- POJ 2385 Apple Catching 动态规划
- Struts拦截器判断用户是否登陆
- Running GUI apps with Docker
- as笔记3
- 头疼的算法与数据结构——详解选择排序法
- 数据结构实验之链表五:单链表的拆分
- 论文推荐 Spark
- 安卓EditText-实现输入小数点后几位的逻辑演变
- 密度聚类算法(三)
- Unity Shader中法线变换
- # 机器学习笔记2——参数学习、非参数学习、局部加权线性回归、线性回归的概率解释、logistics回归