Skip to content

Instantly share code, notes, and snippets.

@warp1337
Last active March 29, 2021 11:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save warp1337/3ebe461af606046f382e50b584705e1c to your computer and use it in GitHub Desktop.
Save warp1337/3ebe461af606046f382e50b584705e1c to your computer and use it in GitHub Desktop.
Running Margin in Docker
# 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/*

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.

  1. 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.
  2. Install Docker-ce on your host system [Ubuntu https://docs.docker.com/install/linux/docker-ce/ubuntu/]
  3. 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.
  4. 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/*
  1. 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
  1. 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!
  1. 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.sh

Well, 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!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment