Recently, I virtualized almost everything with Docker.
Finally I virtualized my Emacs with GUI because I am using Arch Linux which cannot provide
fcitx-mozc for package namespace collision.
So I installed Emacs with X11 client in Docker container, then display Emacs screen to Host's X11 server.
- Host OS：Arch Linux
- Guest OS：Debian GNU/Linux
- Docker version： 1.12.1
First of all, write quite simple
Dockerfile. Hopefully install some tools like
FROM debian:latest RUN apt-get update RUN apt-get -y install emacs24 RUN useradd -G sudo -u 1000 --create-home emacs ENV HOME /home/emacs WORKDIR /home/emacs CMD /usr/bin/emacs --reverse
docker build --tag emacs . in the directory with above
Next, create a launch script and put it to a directory.
$PATH must include the directory.
#!/bin/bash xhost +local: docker run -it --rm \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v $HOME:/home/emacs/host_home \ -e DISPLAY=$DISPLAY \ --user 1000 \ emacs xhost -local:
The above code just do
$DISPLAYenv var to the container
$HOMEdirectory for general usage
/tmp/.X11-unixbetween host and container to connect X11 socket
Finally launch emacs:
To check the host and guest interaction let's run
dired emacs file explorer.
$HOME of host is mounted to the container.
In the container these files owner are recognized as Docker executing user(emacs). cause the UID
- If HOST UID and GUEST UID does not match, we cannot edit files for permission problem.
- We cannot use Symbolic link in the container like Docker, LXC. This is sometimes really inconvenient.
This post is a kind of joke to some extent, but I will use emacs-docker actively.
/tmp/.XIM-unix directory. If we mount it then possibly we can virtualize XIM functions.
Container is a dream.