How to open Ubuntu GUI inside a Docker image

99封情书 提交于 2019-12-03 05:10:28
VonC

Generally, the approach for developing with Docker is to keep the IDE on the workstation, and build images with the binary produced from the sources.

You can find many example of such a workflow (local compilation, deployment in Docker containers) in domeide.github.io/ (Docker meets the IDE!)
For example: Docker Tools for VisualStudio allows for a tight integration between your editor and Docker processes.

(But this is for Visual Studio 2015, not Visual Studio Code.)

fcwu/docker-ubuntu-vnc-desktop

https://github.com/fcwu/docker-ubuntu-vnc-desktop provides a convenient setup:

docker run --name ubvnc -p 6080:80 -p 5900:5900 dorowu/ubuntu-desktop-lxde-vnc:bionic

Then either:

  • visit: http://127.0.0.1:6080/#/ which runs a noVNC more limited JavaScript VNC client

  • run:

    sudo apt-get install tigervnc-viewer
    xtigervncviewer :5900
    

    Then inside vinagre, you might want to go into full screen mode to be able to see the full desktop

    I also tried vinagre, but it was much laggier when scrolling Firefox on YouTube.

To quit just kill docker on the terminal. And to restart the machine

docker start ubvnc

and then reconnect with VNC. Then to quit the machine:

docker stop ubvnc

You have to wait a few seconds for the VNC server on the guest to start before you can connect.

Chromium won't start from the menu. If you try to launch it from the command line it explains why:

Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

Firefox does not care however.

TODO: no audio. --device /dev/snd did not help:

See also:

Tested on Ubuntu 19.04 host, fcwu/docker-ubuntu-vnc-desktop, dorowu/ubuntu-desktop-lxde-vnc image id: 70516b87e92d.

Jürgen Weigert

You can directly connect a Docker container to your X server.

See Stack Overflow question Can you run GUI applications in a Docker container?.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!