Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ sync
docker-compose.yml

# Runtime files
config/
anki_data/
*.log

47 changes: 47 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build & Push (Docker Hub)

on:
push:
branches: [ "main" ]
tags: [ "v*.*.*" ]
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract repo name
id: repo
run: echo "name=${GITHUB_REPOSITORY#*/}" >> $GITHUB_OUTPUT

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.repo.outputs.name }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha

- name: Build & push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.env
docker-compose.yml
# Ignore everything in config
anki_data/*

# But don't ignore these specific files
!anki_data/.gitkeep
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ RUN apt-get update && \
libxcb-xinerama0 \
libxcb-cursor0 \
python3-xdg \
lame \
mplayer \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -22,10 +24,8 @@ RUN dpkg --remove anki && \
cd anki-launcher-${ANKI_VERSION}-linux && ./install.sh && cd .. && \
rm -rf anki-launcher-${ANKI_VERSION}-linux anki-launcher-${ANKI_VERSION}-linux.tar.zst

# Create a config directory to be mounted and add symbolic links to Anki's real config directories
RUN mkdir -p /config/.local/share && \
ln -s /config/app/Anki /config/.local/share/Anki && \
ln -s /config/app/Anki2 /config/.local/share/Anki2
# Create a config directory to be mounted
RUN mkdir -p /config/.local/share

COPY ./root /

Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Lua 🌈

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.
71 changes: 49 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This project is inspired by [pnorcross/anki-desktop-docker](https://github.com/p

Why? Because it makes automating Anki (with addons like AnkiConnect) easier.

The Anki desktop app runs in a browser (via VNC) on port `3000`. Your Anki data is stored in a volume mounted at `/config/app` inside the container.
The Anki desktop app runs in a browser (via VNC) on port `3000`. Your Anki data is stored in `anki_data` mounted as a volume at '/config` inside the container.

---

Expand All @@ -21,7 +21,7 @@ The Anki desktop app runs in a browser (via VNC) on port `3000`. Your Anki data
## Files in This Repo

### `Dockerfile`
Builds the container with Anki 25.02.7 You can change the Anki version, but compatibility may vary.
Builds the container with Anki 25.07.5 You can change the Anki version, but compatibility may vary.

### `docker_installation`
Contains commands to install Docker on Ubuntu.
Expand All @@ -37,52 +37,79 @@ Also uses `curl` to call AnkiConnect. It forces a sync and optionally reschedule

---

## Docker Compose Setup
## How to run

If you want you can run this using the image `mlcivilengineer/anki-desktop-docker` which is automatically built using Github Actions in this repo. Use the following command:
```bash
docker run -d \
--name anki-desktop \
-e PUID=1000 \
-e PGID=1000 \
-v "$(pwd)/anki_data:/config" \
-p 3000:3000 \
-p 8765:8765 \
mlcivilengineer/anki-desktop-docker:main
```

Then open your browser and head to:

```
http://localhost:3000
```

Press Enter after Anki is installed for the first time. Now you can use it as normal. In order to sync with the other clients, put your sync information in the Sync tab.

Create a `docker-compose.yml` in the root of the repo:

## Docker Compose Setup

If you prefer docker compose instead, use the `docker-compose.yml` in the root of the repo:
```yaml
services:
anki-desktop:
build:
services:
anki-desktop:
image: mlcivilengineer/anki-desktop-docker:main
build:
context: ./
dockerfile: Dockerfile
environment:
- PUID=1000
- PGID=1000
volumes:
- ~/.local/share/Anki2:/config/app/Anki2
- ~/backups:/config/app/backups
ports:
- 3000:3000
# Anki Connect port
- 8765:8765
- ./anki_data:/config
ports:
- 3000:3000 # Web UI
- 8765:8765 # AnkiConnect

````

* The **first volume** maps your local Anki data (on Ubuntu it's usually at `~/.local/share/Anki2`) into the container.
* The **second volume** is for backups you extract via AnkiConnect.

To get started:

```bash
git clone <this-repo>
cd anki-desktop-docker
docker compose up --build -d
docker compose up -d
```

Then open your browser and head to:
---

```
http://localhost:3000
## Optional: CJK Font Support

If you need support for Chinese, Japanese, or Korean (CJK) characters in your Anki cards, you can enable this by uncommenting the following environment variables in the `docker-compose.yml` file:

```yaml
environment:
- PUID=1000
- PGID=1000
# Uncomment the following lines to enable CJK font support
- DOCKER_MODS=linuxserver/mods:universal-package-install
- INSTALL_PACKAGES=language-pack-zh-hans|fonts-arphic-ukai|fonts-arphic-uming|fonts-ipafont-mincho|fonts-ipafont-gothic|fonts-unfonts-core
```

---
After making these changes, rebuild your container for the changes to take effect.

## AnkiConnect Configuration

Make sure your AnkiConnect config (inside Anki) looks like this:

If you want to expose the Anki client to http requests, make sure to install the [AnkiConnect](https://ankiweb.net/shared/info/2055492159) Add-on and to configure the Add-on with:
```json
{
"apiKey": null,
Expand Down
Empty file added anki_data/.gitkeep
Empty file.
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
anki-desktop:
image: mlcivilengineer/anki-desktop-docker:main
build:
context: ./
dockerfile: Dockerfile
environment:
- PUID=1000
- PGID=1000
# Uncomment the following lines to enable CJK font support
# - DOCKER_MODS=linuxserver/mods:universal-package-install
# - INSTALL_PACKAGES=language-pack-zh-hans|fonts-arphic-ukai|fonts-arphic-uming|fonts-ipafont-mincho|fonts-ipafont-gothic|fonts-unfonts-core
volumes:
- ./anki_data:/config
ports:
- 3000:3000 # Web UI
- 8765:8765 # AnkiConnect
4 changes: 0 additions & 4 deletions root/defaults/autostart
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Set layout to avoid keybinding warnings
setxkbmap -layout us &

sudo chown -R 1000:1000 /config/app && \
mkdir -p /config/app/Anki2 && \
mkdir -p /config/app/Anki

export DISABLE_QT5_COMPAT=1
export LC_ALL=en_US.UTF-8

Expand Down
2 changes: 1 addition & 1 deletion root/defaults/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<menu id="root-menu" label="MENU">
<item label="Anki">
<action name="Execute">
<command>/usr/bin/anki</command>
<command>/usr/local/bin/anki</command>
</action>
</item>
<item label="xterm" icon="/usr/share/pixmaps/xterm-color_48x48.xpm">
Expand Down