Skip to content

Instantly share code, notes, and snippets.

@ondrik
Forked from rmoehn/Dockerfile
Last active August 26, 2022 08:09
Show Gist options
  • Save ondrik/95850021e9046483df91c46d9a23ad2b to your computer and use it in GitHub Desktop.
Save ondrik/95850021e9046483df91c46d9a23ad2b to your computer and use it in GitHub Desktop.
Dockerfile for running Anki inside a Docker Container on Debian Stable
# Credits:
#
# - http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
# - https://github.com/jfrazelle/dockerfiles/blob/master/spotify/Dockerfile
#
# Prepare (example):
#
# $ mkdir AnkiDocker
# $ cd AnkiDocker
# $ # Save this file to Dockerfile and adapt it to your needs.
# $ mkdir config
# $ docker build -t debian-anki .
#
# First run:
#
# $ docker run -ti --rm -e DISPLAY="unix$DISPLAY" --net=host debian-anki bash
# (docker)$ fcitx-autostart
# (docker)$ fcitx-configtool
#
# [set up fcitx]
#
# Run (example):
#
# $ docker run -ti --rm -e DISPLAY=unix$DISPLAY \
# -v $HOME/Anki:/home/anki-user/Anki \
# -v $(pwd)/config:/home/anki-user/.config \
# -v $HOME/.Xauthority:/home/anki-user/.Xauthority \
# --net=host debian-anki
FROM debian:stable
RUN apt-get update
# Credits: https://wiki.debian.org/Locale
RUN apt-get install -y aptitude
RUN aptitude install -y locales
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen
# fonts-vlgothic is for Japanese fonts. Depending on what you study with
# Anki, you might want to install other packages.
RUN aptitude install -y fonts-vlgothic
RUN aptitude install -y fonts-arphic-uming fonts-wqy-zenhei
RUN aptitude install -y fcitx fcitx-chewing
RUN aptitude install -y dbus-x11 x11-xkb-utils
RUN aptitude install -y anki
# Might only work if your host user and group IDs are both 1000.
ENV HOME /home/anki-user
RUN useradd --create-home --home-dir $HOME anki-user \
&& chown -R anki-user:anki-user $HOME
WORKDIR $HOME
USER anki-user
ENV LANG en_US.UTF-8
ENV XMODIFIERS @im=fcitx
# ENV XMODIFIERS @im=ibus
# CMD /bin/bash -c "(/usr/bin/ibus-daemon -xd; /usr/bin/anki;)"
CMD /bin/bash -c "/usr/bin/fcitx-autostart ; /usr/bin/anki"
# The MIT License (MIT)
#
# Copyright (c) 2016 Richard Möhn
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment