Docker has dozents of advantages and so is one of them to be able to use apps with a GUI isolated in a docker container. For example your Browser, TextEditor or something else.
Neatless to say that this will enable you to use linux / macOS software on your windows host without messing with some hacks. Also this will prevent your maschine from having leftover dependencies when removing the app because it all stays wrapped up in a docker container.
I use Arch Linux on my private computer at home and Windows 10 at work. I wanted to be able to use the Evolution mail client and other handy linux apps on my windows maschine.
So there are various tutorials on how to share an X11-Session from a linux host with a linux container. But:
First of all, install VcXsrv Windows X Server. We could use Xming also, but the package for windows hasn't been updated since 2013. The easiest way would be to use Chocolatey which is by the way my favorite package manager for windows!
So fire up a powershell session and run:
choco install vcxsrv
To use a simple example, create a new folder and place a Dockerfile with the following content in it:
FROM ubuntu:14.04 RUN apt-get update && apt-get install -y firefox CMD /usr/bin/firefox
For advanced docker users, here the quick commands:
docker build -t firefox . set-variable -name DISPLAY -value YOUR-IP:0.0 docker run -ti --rm -e DISPLAY=$DISPLAY firefox
Now build the new container and label it firefox:
docker build -t firefox .
Because the container has its own localhost interface, we need to use the IP-address of our network adapter.
Find out your ip address with
Set the environment variable (replace IP with yours):
set-variable -name DISPLAY -value 10.11.128.118:0.0
Run the container:
docker run -ti --rm -e DISPLAY=$DISPLAY firefox
This will work most other apps.
To persist data (like for evolution mail), start the container with the correct locations mounted via a docker volume.
Find out all the locations, where your app stores data you want to persist and mount them:
docker run -v c:/docker/evolutionmail/home/user/.local/share/evolution:/root/.local/share/evolution -v c:/docker/evolutionmail/home/user/.config/evolution:/root/.config/evolution -ti --rm -e DISPLAY=$DISPLAY evolution
Here is my evolution Dockerfile in case someone needs it:
FROM debian # Setup enviroment variables ENV DEBIAN_FRONTEND noninteractive # Installing fuse filesystem is not possible in docker without elevated priviliges # but we can fake installling it to allow packages we need to install for GNOME RUN apt-get install libfuse2 -y && \ cd /tmp ; apt-get download fuse && \ cd /tmp ; dpkg-deb -x fuse_* . && \ cd /tmp ; dpkg-deb -e fuse_* && \ cd /tmp ; rm fuse_*.deb && \ cd /tmp ; echo -en '#!/bin/bash\nexit 0\n' > DEBIAN/postinst && \ cd /tmp ; dpkg-deb -b . /fuse.deb && \ cd /tmp ; dpkg -i /fuse.deb # Upstart and DBus have issues inside docker. RUN dpkg-divert --local --rename --add /sbin/initctl && ln -sf /bin/true /sbin/initctl # Install GNOME RUN apt-get update && apt-get install -y xorg gnome-core gnome-session-fallback # Pull in the hack to fix keyboard shortcut bindings for GNOME 3 ADD https://raw.githubusercontent.com/CannyComputing/Dockerfile-Ubuntu-Gnome/master/gnome-keybindings.pl /usr/local/etc/gnome-keybindings.pl RUN chmod +x /usr/local/etc/gnome-keybindings.pl # Add the script to fix and customise GNOME for docker ADD https://raw.githubusercontent.com/CannyComputing/Dockerfile-Ubuntu-Gnome/master/gnome-docker-fix-and-customise.sh /usr/local/etc/gnome-docker-fix-and-customise.sh RUN chmod +x /usr/local/etc/gnome-docker-fix-and-customise.sh RUN apt-get update -y && apt-get install -y dbus-x11 gnome-keyring evolution evolution-data-server seahorse sudo RUN apt-get install -y libnotify-cil-dev CMD ["evolution"]
I am curious to see what you dockerized in the comments!
Learning to code products doesn't take as long as you think - more precisely, 300 hours to learn, build, and launch. Learn about the history and misconceptions of development preventing you from even starting and then hop on that tech bus.