Skip to content

Instantly share code, notes, and snippets.

@afbjorklund
Last active October 13, 2023 17:47
Show Gist options
  • Save afbjorklund/cb63251c43f73a4314ada904ae8f8d87 to your computer and use it in GitHub Desktop.
Save afbjorklund/cb63251c43f73a4314ada904ae8f8d87 to your computer and use it in GitHub Desktop.
Boot2Docker with X11 Desktop

Boot2Docker with X11 Desktop

The regular Boot2Docker ISO has a command line environment (CLI). But it can also be useful to have a graphical environment (GUI)...

The distribution on which it is based, Tiny Core Linux, has two main images available: "Core" and "TinyCore" (with Xorg, and a desktop)

http://www.tinycorelinux.net/

This makes it possible to produce an alternative boot2docker-x11.iso, that starts a local X11 server - after first booting into Docker as usual:

Containers

You can mount the X11 socket from this server in your Docker machine, to enable your containers to have a graphical interface (a $DISPLAY):

docker run -e DISPLAY=:0 -v /tmp/.X11-unix:/tmp/.X11-unix ...

Since this only exposes the machine X11 server, it is still "safe" unlike exposing your regular X11 server socket to the container.

See https://github.com/mviereck/x11docker for more details on that.

This particular image also enables X11 forwarding, so you can use that instead if you prefer and have the possibility (are running X).

docker-machine ssh default -X

Building

You build this ISO, by using the normal ISO build environment as a base. Note that this requires a couple of GB of memory and disk...

docker build -f Dockerfile.x11 -t boot2docker-x11 .
docker run --rm boot2docker-x11 > boot2docker-x11.iso

Applications

You can use the provided Apps icon, to download and install more desktop applications. They will load into RAM, just like the rest.

As usual, if you want anything to survive a restart you will need to use the /var/lib/boot2docker mount - instead of the temporary filesystem.


Thanks to Boot2Docker, and Tiny Core Linux!

Written by Anders Björklund (@afbjorklund)

@pklapperich
Copy link

Where can I find a Dockerfile.x11 to use for these instructions?

@afbjorklund
Copy link
Author

@pklapperich
Copy link

Looks like it'll take some work to build based on the current boot2docker.

But your premade ISO still works with docker-machine create --virtualbox-boot2docker-url ... and I'm able to run a container (headless, but still requires X11) on Mac that I couldn't before. Unfortunately I think I've run into a wall with UDP networking issues preventing that container from doing anything useful once it starts. But it starts! =D

@afbjorklund
Copy link
Author

Most likely it would need to be rebased, from Tiny Core Linux 7.x to 10.x ? Apparently the $TCL_REPO_BASE was removed in a major refactoring, so it now it uses a list of mirrors and looks quite different. But the end the upstream URL isn't quite so different from before:

http://distro.ibiblio.org/tinycorelinux/7.x/x86_64/tcz/

http://distro.ibiblio.org/tinycorelinux/10.x/x86_64/tcz/

Probably some of the packages in the list (for X11) have changed as well, it was copied from the default TinyCore list of packages.
The easiest is probably to start the regular ISO, and look at the /usr/local/tce.installed directory (it has all of the currently installed)

http://repo.tinycorelinux.net/10.x/x86_64/release/TinyCorePure64-10.1.iso

Xfbdev
Xlibs
Xprogs
aterm
bzip2-lib
fltk-1.3
flwm
freetype
glib2
graphite
harfbuzz
imlib2
imlib2-bin
libICE
libSM
libX11
libXau
libXdmcp
libXext
libXfont
libXmu
libXt
libffi
libfontenc
libjpeg-turbo
libpng
libxcb
pcre
wbar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment