setup-anki
to see the lists of packages CI installs, and ci.yml to see the build steps that follow.
Build the Docker image
For best results, enable BuildKit (export DOCKER_BUILDKIT=1).
When in this current directory, one can build the Docker image like this:
docker image ls to see that the image has been created.
If one wants to build from the project’s root directory, use this command:
Run the Docker image
Anki starts a graphical user interface, and this requires some extra setup on the user’s end. These instructions were tested on Linux (Debian 11) and will have to be adapted for other operating systems. To allow the Docker container to pull up a graphical user interface, we need to run the following:docker run command:
-
Mount the current user’s
~/.local/sharedirectory onto the container. Anki saves things into this directory, and if we don’t mount it, we will lose any changes once the container exits. We mount this as read-write (rw) because we want to make changes here. -
Mount
/etc/passwdso we can enter the container as ourselves. We mount this as read-only because we definitely do not want to modify this. -
Enter the container with our user ID and group ID, so we stay as ourselves.
-
Mount the X11 directory that allows us to open displays.
-
Pass the
DISPLAYvariable to the container, so it knows where to display graphics.
Running Dockerized Anki easily from the command line
One can create a shell function that executes thedocker run command. Then one can
simply run anki on the command line, and Anki will open in Docker. Make sure to change
the image name to whatever you used when building Anki.