Lately, I have been using a Docker server Linux laptop. On the laptop, I do all; programming, browsing, using Twitter, using Slack, and seeing YouTube. So, I have been running an X Server in a container and using GUI directly.(It’s not directory :)

I will explain the how-to.



0. My laptop is

Ubuntu Server 16.04.3 LTS (64bit)

$ cat /etc/lsb-release 

1. build a container that has an X server and X clients.


FROM ubuntu:16.04
MAINTAINER kunst1080

RUN apt-get update \
        && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
        && DEBIAN_FRONTEND=noninteractive apt-get install -y \
            dbus \
            dbus-x11 \
            xorg \
            xserver-xorg-legacy \
            xinit \
            xterm \
    && rm -rf /var/lib/apt/lists/*

RUN sed -i "s/allowed_users=console/allowed_users=anybody/;$ a needs_root_rights=yes" /etc/X11/Xwrapper.config

ARG user=user
ARG uid=1000
RUN useradd ${user} -u $uid -m -G adm,dialout,cdrom,sudo,audio,dip,video,plugdev,netdev -s /bin/bash

CMD [ "/usr/bin/startx", "--", "vt7" ]
  • The “xserver-xorg-legacy” is needed to run startx from a normal user.
  • The sed script that editing “/etc/X11/Xwrapper.config” is also needed to run startx from normal a user.

2. run the container with the options.

$ docker run --rm --privileged \
    --shm-size=8gb \
    -v /run/udev:/run/udev \
    -v /run/dbus:/run/dbus \
    -v /run/systemd:/run/systemd \
  • --privileged option is needed to display GUI.
  • /run/udev is needed to use mouse and keyboard.
  • /run/dbus and /run/systemd are needed to use systemd. If you do not need systemd, the options are needless.
  • --shm-size option sets the shared memory size. To using applications such as Google Chrome, it’s the needs the large size of shared memory. The default value is only 64MB!

3. My REAL settings

My REAL settings are below:

I am updating them as necessary, cheers.

My workspace