579 字
2 分钟
使用Docker部署Misskey实例
2026-01-16
统计加载中...

前言#

Misskey是一个开源的、去中心化的社交网络平台,它提供了丰富的功能和高度的自定义性,让用户能够自由地构建和管理自己的社交空间。与传统社交媒体不同,Misskey支持联邦宇宙(Fediverse)协议,允许不同实例之间的用户相互交流,同时保持数据的控制权和隐私性。

Docker 构建教程#

拉取 Docker 库#

git clone -b master https://github.com/misskey-dev/misskey.git # 克隆Misskey仓库
cd misskey # 进入Misskey目录
git checkout master # 切换到master分支

配置文件设置#

复制配置文件示例#

使用以下命令复制配置文件的示例文件:

cp .config/docker_example.yml .config/default.yml # 复制Docker示例配置文件
cp .config/docker_example.env .config/docker.env # 复制Docker示例环境变量文件
cp ./compose_example.yml ./compose.yml # 复制Docker Compose示例文件

编辑配置文件#

编辑default.yml#

default.yml是Misskey的主要配置文件:

#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Misskey configuration
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# ┌─────┐
#───┘ URL └─────────────────────────────────────────────────────
# Final accessible URL seen by a user.
# You can set url from an environment variable instead.
url: https://example.tld/ # 你的实例域名
# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE
# URL SETTINGS AFTER THAT!
# ┌───────────────────────┐
#───┘ Port and TLS settings └───────────────────────────────────
#
# Misskey requires a reverse proxy to support HTTPS connections.
#
# +----- https://example.tld/ ------------+
# +------+ |+-------------+ +----------------+|
# | User | ---> || Proxy (443) | ---> | Misskey (3000) ||
# +------+ |+-------------+ +----------------+|
# +---------------------------------------+
#
# You need to set up a reverse proxy. (e.g. nginx)
# An encrypted connection with HTTPS is highly recommended
# because tokens may be transferred in GET requests.
# The port that your Misskey server should listen on.
port: 3000 # 你的实例端口
# ┌──────────────────────────┐
#───┘ PostgreSQL configuration └────────────────────────────────
db:
host: db
port: 5432
# Database name
# You can set db from an environment variable instead.
db: misskey # 数据库名称
# Auth
# You can set user and pass from environment variables instead.
user: example-misskey-user # 数据库用户名
pass: example-misskey-pass # 数据库密码
# Whether disable Caching queries
#disableCache: true
# Extra Connection options
#extra:
# ssl: true
dbReplications: false # 是否启用数据库复制
# You can configure any number of replicas here
#dbSlaves:
# -
# host:
# port:
# db:
# user:
# pass:
# -
# host:
# port:
# db:
# user:
# pass:
# ┌─────────────────────┐
#───┘ Redis configuration └─────────────────────────────────────
redis:
host: redis # Redis 主机名
port: 6379 # Redis 端口
#family: 0 # 0=Both, 4=IPv4, 6=IPv6
#pass: example-pass
#prefix: example-prefix
#db: 1
#redisForPubsub:
# host: redis
# port: 6379
# #family: 0 # 0=Both, 4=IPv4, 6=IPv6
# #pass: example-pass
# #prefix: example-prefix
# #db: 1
#redisForJobQueue:
# host: redis
# port: 6379
# #family: 0 # 0=Both, 4=IPv4, 6=IPv6
# #pass: example-pass
# #prefix: example-prefix
# #db: 1
#redisForTimelines:
# host: redis
# port: 6379
# #family: 0 # 0=Both, 4=IPv4, 6=IPv6
# #pass: example-pass
# #prefix: example-prefix
# #db: 1
#redisForReactions:
# host: redis
# port: 6379
# #family: 0 # 0=Both, 4=IPv4, 6=IPv6
# #pass: example-pass
# #prefix: example-prefix
# #db: 1
# ┌───────────────────────────────┐
#───┘ Fulltext search configuration └─────────────────────────────
# These are the setting items for the full-text search provider.
fulltextSearch:
# You can select the ID generation method.
# - sqlLike (default)
# Use SQL-like search.
# This is a standard feature of PostgreSQL, so no special extensions are required.
# - sqlPgroonga
# Use pgroonga.
# You need to install pgroonga and configure it as a PostgreSQL extension.
# In addition to the above, you need to create a pgroonga index on the text column of the note table.
# see: https://pgroonga.github.io/tutorial/
# - meilisearch
# Use Meilisearch.
# You need to install Meilisearch and configure.
provider: sqlLike # 全文搜索提供程序
# For Meilisearch settings.
# If you select "meilisearch" for "fulltextSearch.provider", it must be set.
# You can set scope to local (default value) or global
# (include notes from remote).
#meilisearch:
# host: meilisearch
# port: 7700
# apiKey: ''
# ssl: true
# index: ''
# scope: local
# ┌───────────────┐
#───┘ ID generation └───────────────────────────────────────────
# You can select the ID generation method.
# You don't usually need to change this setting, but you can
# change it according to your preferences.
# Available methods:
# aid ... Short, Millisecond accuracy
# aidx ... Millisecond accuracy
# meid ... Similar to ObjectID, Millisecond accuracy
# ulid ... Millisecond accuracy
# objectid ... This is left for backward compatibility
# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE
# ID SETTINGS AFTER THAT!
id: 'aidx' # ID 生成方法
# ┌────────────────┐
#───┘ Error tracking └──────────────────────────────────────────
# Sentry is available for error tracking.
# See the Sentry documentation for more details on options.
#sentryForBackend:
# enableNodeProfiling: true
# options:
# dsn: 'https://[email protected]/0'
#sentryForFrontend:
# vueIntegration:
# tracingOptions:
# trackComponents: true
# browserTracingIntegration:
# replayIntegration:
# options:
# dsn: 'https://[email protected]/0'
# ┌─────────────────────┐
#───┘ Other configuration └─────────────────────────────────────
# Whether disable HSTS
#disableHsts: true
# Number of worker processes
#clusterLimit: 1
# Job concurrency per worker
# deliverJobConcurrency: 128
# inboxJobConcurrency: 16
# Job rate limiter
# deliverJobPerSec: 128
# inboxJobPerSec: 32
# Job attempts
# deliverJobMaxAttempts: 12
# inboxJobMaxAttempts: 8
# IP address family used for outgoing request (ipv4, ipv6 or dual)
#outgoingAddressFamily: ipv4
# Proxy for HTTP/HTTPS
#proxy: http://127.0.0.1:3128
proxyBypassHosts: # 代理绕过主机列表
- api.deepl.com
- api-free.deepl.com
- www.recaptcha.net
- hcaptcha.com
- challenges.cloudflare.com
# Proxy for SMTP/SMTPS
#proxySmtp: http://127.0.0.1:3128 # use HTTP/1.1 CONNECT
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
# Media Proxy
#mediaProxy: https://example.com/proxy
# For security reasons, uploading attachments from the intranet is prohibited,
# but exceptions can be made from the following settings. Default value is "undefined".
# Read changelog to learn more (Improvements of 12.90.0 (2021/09/04)).
#allowedPrivateNetworks: [
# '127.0.0.1/32'
#]
# Upload or download file size limits (bytes)
#maxFileSize: 262144000
# Log settings
# logging:
# sql:
# # Outputs query parameters during SQL execution to the log.
# # default: false
# enableQueryParamLogging: false
# # Disable query truncation. If set to true, the full text of the query will be output to the log.
# # default: false
# disableQueryTruncation: false

请将url: https://example.tld/中的example.tld替换为你为Misskey实例分配的实际域名。
同时,db: misskeyuser: example-misskey-userpass: example-misskey-pass分别对应数据库名称、数据库用户名和数据库密码,请根据您的实际数据库配置进行修改,并确保这些凭据与环境变量的设置保持一致。

编辑docker.env#

docker.env文件包含了Docker容器运行所需的环境变量:

# misskey settings
# MISSKEY_URL=https://example.tld/
# db settings
POSTGRES_PASSWORD=example-misskey-pass # 数据库密码(如果修改了default.yml,这里也需要修改)
# DATABASE_PASSWORD=${POSTGRES_PASSWORD}
POSTGRES_USER=example-misskey-user # 数据库用户名(如果修改了default.yml,这里也需要修改)
# DATABASE_USER=${POSTGRES_USER}
POSTGRES_DB=misskey # 数据库名称(如果修改了default.yml,这里也需要修改)
# DATABASE_DB=${POSTGRES_DB}
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}"

如果在default.yml中指定了数据库名称、用户名和密码,请务必确保这些凭据与环境变量保持一致。否则,Misskey将无法成功连接到数据库。

编辑compose.yml#

compose.yml文件定义了 Docker 容器的配置:

services:
web:
build: .
restart: always
links:
- db
- redis
# - mcaptcha
# - meilisearch
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "3000:3000" # 映射主机端口到容器端口
networks:
- internal_network
- external_network
# env_file:
# - .config/docker.env
volumes:
- ./files:/misskey/files
- ./.config:/misskey/.config:ro
redis:
restart: always
image: redis:7-alpine
networks:
- internal_network
volumes:
- ./redis:/data
healthcheck:
test: "redis-cli ping"
interval: 5s
retries: 20
db:
restart: always
image: postgres:18-alpine
networks:
- internal_network
env_file:
- .config/docker.env
volumes:
- ./db:/var/lib/postgresql
healthcheck:
test: "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"
interval: 5s
retries: 20
# mcaptcha:
# restart: always
# image: mcaptcha/mcaptcha:latest
# networks:
# internal_network:
# external_network:
# aliases:
# - localhost
# ports:
# - 7493:7493
# env_file:
# - .config/docker.env
# environment:
# PORT: 7493
# MCAPTCHA_redis_URL: "redis://mcaptcha_redis/"
# depends_on:
# db:
# condition: service_healthy
# mcaptcha_redis:
# condition: service_healthy
#
# mcaptcha_redis:
# image: mcaptcha/cache:latest
# networks:
# - internal_network
# healthcheck:
# test: "redis-cli ping"
# interval: 5s
# retries: 20
# meilisearch:
# restart: always
# image: getmeili/meilisearch:v1.3.4
# environment:
# - MEILI_NO_ANALYTICS=true
# - MEILI_ENV=production
# env_file:
# - .config/meilisearch.env
# networks:
# - internal_network
# volumes:
# - ./meili_data:/meili_data
networks:
internal_network:
internal: true
external_network:

构建镜像与初始化数据库#

使用以下命令进行Misskey的构建和数据库初始化。这可能需要一些时间。

sudo docker compose build # 构建Docker镜像
sudo docker compose run --rm web pnpm run init # 初始化数据库

启动Misskey实例#

完成构建和初始化后,使用以下命令启动Misskey容器:

sudo docker compose up -d # 启动Misskey容器

故障排除#

INTERNAL_ERROR错误处理#

如果访问Misskey实例时遇到以下错误:

Misskey Internal error occurred. Please contact us if the error persists.
INTERNAL_ERROR
5d37dbcb-891e-41ca-a3d6-e690c97775ac

这通常是由于文件权限问题引起的。请将/misskey/files目录权限设置为777:

sudo chmod -R 777 ./files # 设置files目录权限为777

设置完成后,重新启动Misskey容器

更新Misskey#

当有新版本发布时,可以使用以下步骤更新Misskey实例:

git stash # 保存当前工作目录的更改
git checkout master # 切换到master分支
git pull # 拉取最新代码
git submodule update --init # 更新子模块
git stash pop # 恢复之前的更改
sudo docker compose build # 构建新镜像
sudo docker compose stop && sudo docker compose up -d # 重启容器

结语#

通过本教程,您已经成功学习了如何使用Docker部署和管理自己的Misskey实例。从环境准备、配置文件设置到实例的启动和更新,我们一步步完成了整个部署过程。

分享

如果这篇文章对你有帮助,欢迎分享给更多人!

使用Docker部署Misskey实例
https://blog.yuk1.uk/posts/misskey-docker/
作者
SuzuhaYuki
发布于
2026-01-16
许可协议
CC BY-NC-SA 4.0

部分信息可能已经过时

封面
Sample Song
Sample Artist
封面
Sample Song
Sample Artist
0:00 / 0:00