Self-Hosting Apache Answer with Docker Compose

What Is Apache Answer?

Apache Answer is a self-hosted Q&A platform that works like a private StackOverflow. Users ask questions, post answers, vote on quality, and organize knowledge with tags. It’s built by the Apache Software Foundation and supports multiple databases, plugin extensions, and an AI assistant feature in v2.0. Official site

Prerequisites

  • A Linux server (Ubuntu 22.04+ recommended)
  • Docker and Docker Compose installed (guide)
  • 512 MB of free RAM (1 GB recommended with PostgreSQL)
  • 2 GB of free disk space
  • A domain name (optional, for remote access)

Docker Compose Configuration

Create a directory for Answer and a docker-compose.yml file:

mkdir -p ~/answer && cd ~/answer

Option 1: SQLite (Simplest — Good for Small Teams)

services:
  answer:
    image: apache/answer:2.0.0
    container_name: answer
    restart: unless-stopped
    ports:
      - "9080:80"
    volumes:
      - answer-data:/data
    environment:
      # Auto-install skips the web wizard
      - AUTO_INSTALL=true
      # Database — SQLite requires no external services
      - DB_TYPE=sqlite3
      - DB_FILE=/data/sqlite3/answer.db
      # Site settings
      - LANGUAGE=en-US
      - SITE_NAME=Q&A
      - SITE_URL=http://localhost:9080
      - [email protected]
      # Initial admin account — CHANGE THESE
      - ADMIN_NAME=admin
      - ADMIN_PASSWORD=change-this-strong-password
      - [email protected]

volumes:
  answer-data:
services:
  answer:
    image: apache/answer:2.0.0
    container_name: answer
    restart: unless-stopped
    ports:
      - "9080:80"
    volumes:
      - answer-data:/data
    environment:
      - AUTO_INSTALL=true
      - DB_TYPE=postgres
      - DB_HOST=db:5432
      - DB_NAME=answer
      - DB_USERNAME=answer
      - DB_PASSWORD=change-this-db-password
      - LANGUAGE=en-US
      - SITE_NAME=Q&A
      - SITE_URL=https://qa.example.com
      - [email protected]
      - ADMIN_NAME=admin
      - ADMIN_PASSWORD=change-this-strong-password
      - [email protected]
    depends_on:
      db:
        condition: service_healthy
    networks:
      - answer-net

  db:
    image: postgres:16-alpine
    container_name: answer-db
    restart: unless-stopped
    environment:
      - POSTGRES_DB=answer
      - POSTGRES_USER=answer
      - POSTGRES_PASSWORD=change-this-db-password
    volumes:
      - db-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U answer -d answer"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - answer-net

networks:
  answer-net:

volumes:
  answer-data:
  db-data:

Start the stack:

docker compose up -d

Initial Setup

  1. If using AUTO_INSTALL=true, Answer provisions the database and creates the admin account automatically. Access the site at http://your-server-ip:9080.

  2. If you prefer the web-based installer, remove the AUTO_INSTALL and ADMIN_* environment variables, then navigate to http://your-server-ip:9080/install.

  3. Log in with the admin credentials you set in the environment variables.

  4. Go to Admin > Settings to configure:

    • Site name and description
    • User registration (open, invite-only, or closed)
    • SMTP for email notifications
    • Content policies and moderation rules

Configuration

SMTP for Email Notifications

Configure SMTP through the admin panel at Admin > Settings > SMTP. Answer needs email for:

  • User registration verification
  • Password reset
  • Notification emails for new answers and comments

Plugin System

Answer v2.0 supports plugins for extending functionality. Install plugins via the admin panel or by using the apache/answer-with-plugins Docker image with pre-bundled plugins.

Common plugins include:

  • OAuth login (GitHub, Google, OIDC)
  • Search engine integration (Elasticsearch, Meilisearch)
  • Storage backends (S3, local filesystem)
  • Editor extensions (LaTeX math, code highlighting)

Content Organization

  • Tags: Create tags to categorize questions by topic. Tags support hierarchies.
  • Reputation system: Users earn reputation through upvotes, accepted answers, and participation.
  • Roles: Admin, Moderator, and regular users with configurable permissions.

API Access

Answer exposes a REST API at /answer/api/v1/. API keys can be generated in user settings (v2.0+). Swagger documentation is available at the root URL when enabled.

Reverse Proxy

For production use behind a reverse proxy, update SITE_URL to your public domain and configure your proxy to forward to port 9080. See Reverse Proxy Setup.

Example Caddy configuration:

qa.example.com {
    reverse_proxy localhost:9080
}

Backup

SQLite

Back up the entire /data volume:

docker compose stop answer
tar czf answer-backup-$(date +%Y%m%d).tar.gz /var/lib/docker/volumes/answer_answer-data/
docker compose start answer

PostgreSQL

docker compose exec db pg_dump -U answer answer > answer-backup-$(date +%Y%m%d).sql

For a comprehensive backup strategy, see Backup Strategy.

Troubleshooting

Application Fails to Start with Database Error

Symptom: Container exits with “failed to connect to database” or similar. Fix: Verify the DB_HOST, DB_USERNAME, DB_PASSWORD, and DB_NAME match between the Answer and database services. If using PostgreSQL, ensure the database container is healthy before Answer starts (use depends_on with condition: service_healthy).

Web Installer Shows After AUTO_INSTALL

Symptom: Navigating to the site shows the install wizard despite AUTO_INSTALL=true. Fix: Check the container logs with docker compose logs answer. The auto-install may have failed due to incorrect database credentials. Fix the environment variables and restart with a clean volume: docker compose down -v && docker compose up -d.

Users Cannot Register

Symptom: Registration form is not visible or returns an error. Fix: Check Admin > Settings > Site to ensure registration is set to “Open” or “Invite Only” (not “Closed”). If email verification is required, confirm SMTP settings are working.

Slow Performance with SQLite

Symptom: Pages load slowly under moderate traffic. Fix: SQLite works well for small teams (under 50 concurrent users) but degrades with heavy write loads. Migrate to PostgreSQL for production workloads. Export data via the admin panel and reimport after switching DB_TYPE.

Uploaded Images Not Displaying

Symptom: Images in questions and answers show broken links. Fix: Verify the /data volume mount is persistent and the container has write access. Check SITE_URL — if it doesn’t match the actual URL users access, image links will break.

Resource Requirements

ResourceSQLitePostgreSQL
RAM~100-150 MB idle~250-400 MB (app + database)
CPULow — single core sufficientLow — single core sufficient
Disk~100 MB + user content~200 MB + user content + database

Verdict

Apache Answer is the best self-hosted StackOverflow alternative for teams that need structured Q&A with voting, reputation, and tag-based organization. The SQLite option makes it trivially easy to deploy for small teams, while PostgreSQL handles larger communities. The plugin ecosystem (v2.0+) adds OAuth, search, and storage flexibility without bloating the core.

For general discussion forums where threaded conversations matter more than structured Q&A, Discourse is a better fit. For simple comments on a blog or documentation site, Remark42 is lighter. But for “ask a question, get a voted answer” workflows — internal knowledge bases, developer communities, or customer support — Answer is the right tool.

Comments