Giter Club home page Giter Club logo

docker-vnc-xfce4's Introduction

docker-vnc-xfce4

Description

How to run a GUI application inside a docker container, and to access the application within a browser.
The easiest combo is to run

  • Xvfb a virtual X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory
  • a VNC server to be able to access from everywhere
  • noVNC + websockify that allow to do VNC through a browser
  • pulseaudio to share audio device
  • a Window manager into an Ubuntu base image.

It is possible to choose any windows manager, but some are lighter than others. Below, there will be two simple examples with light ones:

The final image size is 1.9Go.

Build the docker image

When building the image it possible to pass a personal timezone

docker build .                \
  --file Dockerfile           \
  --tag docker-vnc-xfce4      \
  --build-arg TZ=Europe/Paris

It takes few minutes to make it.

Usage

The built image expose standard ports:

  • 5900 for VNC access (here are VNC clients)
  • 6080 for noVNC website

So that for browser access the full address is http://localhost:6080/vnc.html.
Applications starts with a simple user context: user (with password user01), and this user has sudo priviledges.

Start docker+vnc+xfce4

The most simple startup command is

docker run --rm                    \
  --interactive                    \
  --tty                            \
  --publish 6080:6080              \
  --publish ${VNC_PORT:-5900}:5900 \
  --name desktop                   \
  --env LANG=fr_FR.UTF-8           \
  docker-vnc-xfce4

Configuration

Some variables can be passed to the docker run command to modify image behavior.

Name Description
DESKTOP_ADDITIONAL_PROGRAMS Automatically starts a program (ratpoison only)
DESKTOP_BACKGROUND_IMAGE Default background image (can be an url)
DESKTOP_ENV Choose desktop environment (between ratpoison and xfce4)
DESKTOP_KEYBOARD_LAYOUT Specify default keyboard layout (format: layout/variant)
DESKTOP_SIZE Define the screen size (default 1280x1024)
DESKTOP_THEME Set the default Xfce4 theme
DESKTOP_VNC_PASSWORD Set a VNC password (default is none)

Example: run Xfce4 in french, with desktop personal settings and sound

docker run --rm                                                                                               \
  --interactive                                                                                               \
  --tty                                                                                                       \
  --volume /run/user/$(id -u)/pulse/native:/run/user/1000/pulse/native                                        \
  --privileged                                                                                                \
  --publish 6080:6080                                                                                         \
  --publish ${VNC_PORT:-5900}:5900                                                                            \
  --name desktop                                                                                              \
  --env DESKTOP_ENV=xfce4                                                                                     \
  --env LANG=fr_FR.UTF-8                                                                                      \
  --env DESKTOP_KEYBOARD_LAYOUT="fr/azerty"                                                                   \
  --env DESKTOP_SIZE="1920x1080"                                                                              \
  --env DESKTOP_THEME="Greybird-dark"                                                                         \
  --env DESKTOP_BACKGROUND_IMAGE="https://upload.wikimedia.org/wikipedia/commons/9/96/Alberi_AlpediSiusi.JPG" \
  docker-vnc-xfce4 /bin/bash

In the ratpoison example a firefox browser is started in the image. To use another application it is necessary to

  • first install it in Dockerfile at line 44: RUN apt-get install -y --no-install-recommends firefox notepadqq (here we add notepadqq)
  • then run it, setting it in DESKTOP_ADDITIONAL_PROGRAMS

Example: run ratpoison with notepadqq in an interactive container

docker run --rm                                        \
  --interactive                                        \
  --tty                                                \
  --privileged                                         \
  --publish 6080:6080                                  \
  --publish ${VNC_PORT:-5900}:5900                     \
  --name desktop                                       \
  --env LANG=fr_FR.UTF-8                               \
  --env DESKTOP_ENV=ratpoison                          \
  --env DESKTOP_SIZE="1024x800"                        \
  --env DESKTOP_ADDITIONAL_PROGRAMS=/usr/bin/notepadqq \
  docker-vnc-xfce4 /bin/bash

For more informations on ratpoison desktop manager see general use page.

Examples

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.