Skip to content

matbb/docker-anki-sync-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This docker image runs your own anki sync server. The most basic command to run the image is :

docker run \
	-v /host/storage/server:/anki/server \
	-v /host/storage/data:/anki/data \
	-p 27701:27701 \
	-d \
	--restart=unless-stopped \
	matb/docker-anki-sync-server

Configuration

The image can be configured by passing environment variables to the docker-run command. Supported environment variables :

  • ANKI_SERVER_URL : git repository of Anki sync server
  • ANKI_SERVER_VCS_SRC : set to "branch" or "tag" to checkout the corresponding branch or tag
  • ANKI_SERVER_BRANCH : branch to checkout
  • ANKI_SERVER_TAG : tag to checkout

The image also stores anki data into /anki/data, and the server git code in /anki/server. If you want to preserve this data across restarts, you need to mount folders from your host into the container. I suggest you do this for both, server repository and your data, as this shortens the time it takes to restart the docker container.

First run

Adding a user

As I am not aware of any method to add a user over the web, I suggest you run the script in server folder manually and create an account for yourself :

$ /path/to/server/code/ankiserverctl.py adduser myusername

This will create an authentication file auth.db and databases with the user's data in collections. Copy both into the data folder before starting the container.

Configuring Anki Sync Server

In order for the image to work, Anki sync server must listen on all interfaces. See the included configuration for details. If you start this image without a production.ini file in your data folder, a suitable configuration file will be copied into your data folder on first run.

Sync to custom server

See https://github.com/dsnopek/anki-sync-server for instructions on how to configure AnkiDesktop and AnkiDroid.

Secure sync

As AnkiDroid currently does not verify the TLS certificate I didn't find it useful to use a web-server proxy. Instead I added a special user to my server, that is used only for forwarding ports. This way I can have a fully secure sync through ssh proxy, on AnkiDroid and AnkiDesktop.

Setting up ssh forwarding

Create an file in /bin/catshell with the following contents

#!/bin/bash
cat 

and make it executable.

Then add a new user to the system and make it user /bin/catshell for its shell. As this is a fake shell, the user will not be able to do anything on your system, except forward ports. We need a shell that just hangs, so that ConnectBot will not disconnect and we can use port forwarding on android. If you know a way of just using a standard fake shell (like /bin/false or /bin/true), please let me know.

Add a user with :

$ sudo adduser --shell /bin/catshell proxyuser

and configure sshd by adding the following

Match User sshproxy
    AllowTcpForwarding yes
    # X11Forwarding no
    # PermitTunnel no
    # GatewayPorts no
    # AllowAgentForwarding no
    # PermitOpen <local ip address:port>
    ForceCommand echo 'This account can only be used for port forwarding'

to the end of /etc/ssh/sshd_config, uncommenting any other options if you are using them in your sshd_config.

Using with AnkiDesktop

Set AnkiDesktop to sync to localhost:27701 forward the port over ssh before starting AnkiDesktop with

$ ssh -L 127.0.0.1:27701:<docker interface ip>:27701 sshproxy@your.host

Using with AnkiDroid

Download and install ConnectBot from f-droid. Set it up to forward a local port over ssh and run it before starting AnkiDroid. You can add a desktop shortcut for this command.

License

The scripts in this image are licensed under the MIT license. AnkiDesktop, AnkiDroid and Anki sync server are provided under their respective software licenses.

Releases

No releases published

Packages

No packages published

Languages