Repository navigation
Docker
Prebuilt images are published on Docker Hub as yafnet/yafnet, one tag per database provider. A Docker Compose file for each provider starts the forum together with its database.
| Database | Compose file | Image tag |
|---|---|---|
| Microsoft SQL Server | docker-compose-SqlServer.yml |
yafnet/yafnet:latest-sqlserver |
| MySQL / MariaDB | docker-compose-MySql.yml |
yafnet/yafnet:latest-mysql |
| PostgreSQL | docker-compose-PostgreSQL.yml |
yafnet/yafnet:latest-postgresql |
| SQLite | docker-compose-Sqlite.yml |
yafnet/yafnet:latest-sqlite |
- Docker with the Compose plugin (
docker compose, Compose v2) - The
yafsrcfolder of the repository with the compose files and thedockerfolder. Run all commands from theyafsrcfolder: the compose files mount the database init scripts from./docker/..., so they only work from there.
-
Open the compose file for your database and change the default password
MyPass@word(see Passwords). -
Start the stack:
docker compose -f docker-compose-SqlServer.yml up -d
-
Open http://localhost:8001 in your browser. On the first start you are redirected to the installation wizard, which creates the database tables and the admin account.
Taking the SQL Server file as an example:
| Service | Purpose | Host port |
|---|---|---|
yafnet |
The forum, listening on port 89 inside the container | 8001 |
sql-server-db |
The database server | 8002 |
sql-server-init |
Runs once: creates the database yaf if it does not exist, then exits |
- |
The forum waits until the database server is healthy and the init container has finished. SQL Server takes about 30 seconds until it is ready, so the forum is not reachable right away.
The MySQL (mariadb, mariadb-init) and PostgreSQL (postgres-db, postgres-init) files are built the same way. The SQLite file only contains the yafnet service.
To change the host port of the forum, edit the ports entry of the yafnet service, e.g. "80:89". Port 8002 exposes the database to the host and can be removed if you don't need it.
All settings from appsettings.json can be overridden with environment variables in the environment section of the yafnet service. Nested keys are separated with a double underscore:
environment:
- ConnectionStrings__DefaultConnection=...
- BoardConfiguration__ConnectionProviderName=Microsoft.Data.SqlClient
- MailConfiguration__Host=smtp.example.com
- MailConfiguration__Port=587
- MailConfiguration__UserName=forum@example.com
- MailConfiguration__Password=secretA list of all board configuration settings can be found on the BoardConfiguration Settings page.
If you put a reverse proxy (nginx, Traefik, Caddy, ...) in front of the forum, the client address is taken from its X-Forwarded-For header. Proxies in private networks, like another container, are trusted automatically. A proxy or CDN in a public network (e.g. Cloudflare) must be added to TrustedProxies (see Reverse proxy and Cloudflare, also for the https links behind a proxy):
environment:
- BoardConfiguration__TrustedProxies__0=173.245.48.0/20
- BoardConfiguration__TrustedProxies__1=103.21.244.0/22The default password MyPass@word appears in several places of each compose file. Change all of them to the same value:
-
SQL Server:
MSSQL_SA_PASSWORDofsql-server-dbandsql-server-init, thehealthcheckcommand ofsql-server-db, and the connection string ofyafnet -
MySQL:
MARIADB_ROOT_PASSWORDofmariadbandmariadb-init, and the connection string ofyafnet -
PostgreSQL:
POSTGRES_PASSWORDofpostgres-db,PGPASSWORDofpostgres-init, and the connection string ofyafnet
The database password is only applied when the database volume is created for the first time. To change it later, change it in the database itself, or remove the volume (this deletes all data).
The forum needs a working SMTP server for registration mails, password resets and notifications. The compose files contain the mail settings as commented-out examples: uncomment them and set MailConfiguration__Host and MailConfiguration__Port (and UserName / Password if the server requires authentication) to your mail server.
Everything the forum needs to keep is stored in named volumes, so it survives docker compose down and container updates:
| Volume | Path in the container | Content |
|---|---|---|
mssql-data, mysql-data, postgresql-data or sqlite-data
|
depends on the database | the database; with SQLite the file /data/yafnet.db
|
yaf-uploads |
/app/wwwroot/uploads |
the uploaded files (attachments, album images) |
yaf-images |
/app/wwwroot/images |
avatars, logos, category, forum and medal images |
yaf-backups |
/app/App_Data/Backups |
the database backups, see Database backup |
docker compose down -v removes the volumes and deletes all forum data.
A new, empty volume is filled with the files of the image (e.g. the default medals) when it is mounted the first time. After that the volume keeps its content: images that a newer version of YAF.NET adds to wwwroot/images are not copied into an existing yaf-images volume.
With StaticFilesRoot or MultiBoardFolders the uploads and images are in other folders (e.g. wwwroot/1/uploads for board 1); mount a volume to each of them instead.
Warning
The compose files before v4.0.12 didn't store wwwroot/uploads and wwwroot/images in a volume, they were deleted when the container was recreated, e.g. by an update. If your compose file doesn't have the volumes yaf-uploads and yaf-images yet, see Upgrade YAF.NET v4 - Docker before you update.
All compose files mount the named volume yaf-backups to /app/App_Data/Backups: the backups of Host > Database > Database Backup (the database with the uploads and images) are stored there and survive container updates. With SQL Server the volume is also mounted into sql-server-db (/var/opt/mssql/backup, set as BoardConfiguration__SqlServerBackupFolder), because SQL Server writes the backup file itself; the service sql-server-backup-init runs once and gives SQL Server write access to the volume. See Database Backup.
The volume is on the same server as the forum: download the backups regularly or copy them somewhere else.
# show the logs of the forum
docker compose -f docker-compose-SqlServer.yml logs -f yafnet
# stop the stack (data is kept)
docker compose -f docker-compose-SqlServer.yml down
# update to the latest image
docker compose -f docker-compose-SqlServer.yml pull
docker compose -f docker-compose-SqlServer.yml up -dEach provider has its own Dockerfile in the yafsrc/docker folder (docker/yaf-sqlserver, docker/yaf-mysql, docker/yaf-postgresql, docker/yaf-sqlite). The build context is the yafsrc folder:
docker build -f docker/yaf-sqlserver/Dockerfile -t yafnet:sqlserver .To use your own image, replace the image of the yafnet service in the compose file with your tag.
The docker-compose-*-test.yml files are used by the UI tests (DockerComposeFixture). They build the image from the local source instead of pulling it, send mails to a test SMTP server on the host (host.docker.internal:2525) and raise the rate limit, because all test requests come from one IP address. They can also be used to try out local changes:
docker compose -f docker-compose-SqlServer-test.yml up --build -dDon't use them for a real forum.
YetAnotherForum.NET (YAF) the Open Source Discussion Forum for ASP.NET - https://YetAnotherForum.NET - Support me on Ko-fi
Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
Getting started
- About YAF.NET
- Features
- Docker
- Installation (IIS)
- Hosting on Linux with nginx
- Integration (ASP.NET Core)
- Update v4 to a newer v4
- Upgrade from v3 to v4
Configuration
Administration
- Admin guide
- Forums and categories
- Users, roles and permissions
- Board settings
- Host settings
- Content
- Mail and notifications
- Spam protection
- Maintenance
- Boards, languages, page access
- Database backup
- Private forum
- Change the board logo
- Themes
Help
Development
Legacy (v3 and older)