# Run Margin in Docker
**DISCLAIMER** This is no official margin support channel/document. However, it might help you to run the terminal on some esoteric or outdated Linux distros. _Note_: You need to be connected to the internet in order to build the docker image (downloads updates during build) Use at your own risk.
0) Download margin [https://margin.de] and extract it to, e.g, $HOME/Downloads/
You should now see:
$HOME/Downloads/margin-linux
If you already have a copy, adjust paths accordingly please.
1) Install Docker-ce on your host system [Ubuntu https://docs.docker.com/install/linux/docker-ce/ubuntu/]
2) Configure Docker as *non-root* [Ubuntu https://docs.docker.com/v17.09/engine/installation/linux/linux-postinstall/]
You need to logout and login in order to make the changes as non-root effective.
3) Now, build a Docker image based on Ubuntu Bionic (18.04) + XServer. In order to accomplish this, paste the following in a file named 'Dockerfile'
touch $HOME/Dockerfile. Open in editor of your choice and paste the code below.
# Download official ubuntu 18.04 base image FROM ubuntu:18.04 # Update software repository RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && apt-get update && apt-get -y upgrade # Install LXDE and super minimal deps RUN DEBIAN_FRONTEND=noninteractive apt-get install -y lxde-core lxterminal libfontconfig1 mesa-common-dev \ libglu1-mesa-dev libasan4 libubsan0 gdb nano libxcb-xkb-dev libxkbcommon-* # Clean up RUN rm -rf /var/lib/apt/lists/*4) Next, create a folder named margin-docker and move the 'Dockerfile' into this folder -
mkdir -p $HOME/margin-docker; mv $HOME/Dockerfile $HOME/margin-docker/Dockerfile
5) Now run...
- cd $HOME/margin-docker
- docker build -t ubuntu18x --no-cache . Don't forget the tailing .
This may take while, but you are almost done!
6) Okay, great. So what we will do now is:
- a) Mount the margin folder (from Downloads) in the container
- b) Also mount your ~/.margin in the container
- c) Connect your X server to the container
- d) Run margin in the container.
Just execute the command lines below (dont forget the xhost +).
xhost + docker run -ti --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" \ --volume="$HOME/Downloads/margin-linux:/margin-linux" --volume="$HOME/.margin:/root/.margin" \ --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged ubuntu18x /margin-linux/run-margin.shWell, this is **great**, isn't it? You should see margin running on your machine inside the docker container. # Troubleshooting In case the container doesn't build due to, e.g, 404 errors try (in acending order) -
docker rmi --force ubuntu18x Then try to rebuild ubuntu18x as described above
- docker system prune -a **CAUTION** this deletes all existing images, you will need to rebuild them!