Skip to content

Pubky Docker

Pubky Docker is a Docker Compose orchestration that provides a one-click local development environment for running the complete Pubky Social (App) stack. It’s designed for developers who want to experiment with the full Pubky ecosystem or test components in an isolated environment.

Pubky Docker orchestrates the following components:

  1. PKARR Relay - DHT relay for public key-addressable records
  2. Pubky Homeserver - Decentralized data storage instance
  3. Pubky Nexus - Social media indexer and aggregator
  4. Pubky App - Social media client frontend

The orchestration includes all necessary supporting infrastructure (PostgreSQL, Neo4j, Redis) and is configurable for both testnet and mainnet environments.

  • Experimenting with the complete Pubky Social stack
  • Developing or testing Pubky Nexus integrations
  • Building custom social media frontends
  • Testing Homeserver configurations
  • Learning how all Pubky components interact
  • Debugging cross-component issues
  • Building applications using Pubky Core (use SDK libraries instead)
  • Developing simple Pubky integrations (use official client libraries)
  • Just testing basic read/write operations

For application development, use the official client libraries:

This is the fastest way to get started. All images are available on Docker Hub.

  1. Clone the repository:
Terminal window
git clone https://github.com/pubky/pubky-docker.git
cd pubky-docker
  1. Configure environment:
Terminal window
cp .env-sample .env
# Edit .env to set NETWORK=mainnet or NETWORK=testnet
  1. Start the stack:
Terminal window
docker compose up -d

If you need to modify components or build custom versions:

  1. Clone all required repositories at the same directory level:
Terminal window
# Create a workspace directory
mkdir pubky-workspace && cd pubky-workspace
# Clone all repositories
git clone https://github.com/pubky/pubky-docker.git
git clone https://github.com/pubky/pkarr.git
git clone https://github.com/pubky/pubky-core.git
git clone https://github.com/pubky/pubky-nexus.git
git clone https://github.com/pubky/pubky-app.git
  1. Configure and start:
Terminal window
cd pubky-docker
cp .env-sample .env
# Edit .env as needed
docker compose up

The directory structure must be:

pubky-workspace/
├── pubky-docker/
├── pkarr/
├── pubky-core/
├── pubky-nexus/
└── pubky-app/

Local DHT relay for public key-addressable resource records. Enables domain resolution for Pubky identities.

Configuration: pkarr.config.toml

2. Pubky Homeserver (Ports 6286-6288, 15411-15412)

Section titled “2. Pubky Homeserver (Ports 6286-6288, 15411-15412)”

Local instance of a Pubky Homeserver with PostgreSQL backend.

Configuration: homeserver.config.toml

Database: PostgreSQL (Port 5432)

Endpoints:

  • 6287: Primary HTTP API
  • 6286: Admin API
  • 6288: Metrics
  • 15411-15412: HTTP relay

Social media indexer and aggregator with graph database and search capabilities.

Configuration: pubky-nexus-config-{testnet|mainnet}.toml

Dependencies:

  • Neo4j graph database (Ports 7474, 7687)
  • Redis search index (Ports 6379, 8001)

Endpoints:

  • 8080: Main API
  • 8081: Admin/metrics

Next.js-based social media frontend configured to use the local stack.

Access: http://localhost:4200

Configuration is managed through a .env file. Copy the sample and adjust as needed:

Terminal window
cp .env-sample .env

See .env-sample in the repository for all available variables and their defaults.

The stack uses a custom Docker bridge network (172.18.0.0/16) with static IPs:

ServiceIPExternal Ports
PKARR172.18.0.26882
Nexus172.18.0.38080, 8081
Homeserver172.18.0.46286-6288, 15411-15412
Neo4j172.18.0.57474, 7687
Redis172.18.0.66379, 8001
Client172.18.0.74200
Postgres172.18.0.95432
Terminal window
docker compose up -d
Terminal window
# All services
docker compose logs -f
# Specific service
docker compose logs -f homeserver
docker compose logs -f nexusd
Terminal window
docker compose down
Terminal window
docker compose build
docker compose up -d
Terminal window
docker compose down -v
rm -rf .storage/
  1. Modify code in ../pubky-core/
  2. Rebuild Homeserver:
Terminal window
docker compose build homeserver
docker compose up -d homeserver
  1. Modify code in ../pubky-nexus/
  2. Rebuild nexus:
Terminal window
docker compose build nexusd
docker compose up -d nexusd
  1. Modify code in ../pubky-app/
  2. Rebuild client:
Terminal window
docker compose build client
docker compose up -d client

All data is stored in the .storage/ directory:

.storage/
├── pkarr/ # PKARR relay cache
├── postgres/ # Homeserver database
├── neo4j/ # Nexus graph data
├── redis/ # Nexus search index
└── static/ # Nexus static files

This directory is gitignored. To reset your environment, simply delete it.

Check if ports are already in use:

Terminal window
# Check port availability
lsof -i :4200 -i :6882 -i :8080

Ensure PostgreSQL is healthy:

Terminal window
docker compose ps postgres
docker compose logs postgres

Verify Homeserver is running and accessible:

Terminal window
curl http://localhost:6287/
docker compose logs homeserver
Terminal window
# Stop service
docker compose stop nexusd
# Remove its data
rm -rf .storage/neo4j .storage/redis
# Restart
docker compose up -d nexusd

The Pubky Docker stack demonstrates the full architecture of a Pubky Social application:

┌─────────────────────────────────────────────────────┐
│ Browser │
│ (localhost:4200) │
└────────────────────┬────────────────────────────────┘
┌────────────────────▼────────────────────────────────┐
│ Pubky App (Client) │
│ Next.js Frontend │
└────────────┬──────────────────────┬─────────────────┘
│ │
┌────────▼─────────┐ ┌────────▼──────────┐
│ Pubky Nexus │ │ Pubky Homeserver │
│ (Social API) │ │ (User Storage) │
│ - Neo4j Graph │ │ - PostgreSQL │
│ - Redis Search │ │ - File Storage │
└────────┬─────────┘ └────────┬──────────┘
│ │
└──────────┬───────────┘
┌──────▼───────┐
│ PKARR Relay │
│ (DHT/DNS) │
└──────────────┘