Docker Deployment
Pigsty is designed for native Linux, but can also run in Linux containers with systemd. If you don’t have native Linux (e.g., macOS or Windows), use Docker to spin up a local single-node Pigsty for testing.
Quick Start
Enter the docker/ dir in Pigsty source and launch with one command:
After deployment, access services:
| Service | URL / Command | Credentials |
|---|---|---|
| SSH | ssh root@localhost -p 2222 |
Password: pigsty |
| Web Portal | http://localhost:8080 | - |
| Grafana | http://localhost:8080/ui | admin / grafana_admin_password |
| PostgreSQL | psql 'postgres://dbuser_dba:<pg_admin_password>@localhost:5432/postgres' |
pg_admin_password |
make launch runs ./configure -g internally to generate random passwords. You can check them with:
Web Portal and PostgreSQL are only available after Deployment (./deploy.yml) completes.
Prepare
Docker deployment requires:
| Item | Requirement | Item | Requirement |
|---|---|---|---|
| Docker | Docker 20.10+ (Desktop or CE) | CPU | At least 1 core |
| RAM | At least 2GB | Disk | At least 20GB free |
Ensure default host ports (2222/8080/8443/5432) are available, or edit .env first.
- Quick Pigsty experience on macOS/Windows without native Linux
- Learning and testing Pigsty features, dev and debug
- Quick local PostgreSQL dev environment
- Production: Container perf and stability inferior to native Linux
- HA Clusters: Docker single-node mode can’t achieve multi-node HA
- Large Scale: Use native Linux VMs or physical machines
Image
Pigsty provides an out-of-the-box Docker image on Docker Hub.
| Image | Pull | Size | Contents |
|---|---|---|---|
pgsty/pigsty |
~500MB | 1.3GB | Debian 13 + systemd + SSH + pig + Ansible |
- Supports both amd64 (x86_64) and arm64 (Apple Silicon, AWS Graviton)
- Image tags follow Pigsty versions. The Docker configuration on the current
mainbranch and the site baseline both usev5.0.0-preview; verify that the matching remote image exists before pulling or deploying. - Pre-configured with docker template, ready to run
./deploy.yml
Built on Debian 13 (Trixie), pre-installed with pig CLI and Ansible, Pigsty source already initialized.
Launch
Pigsty provides out-of-the-box Docker support in the docker/ source directory.
Simplest way is make launch, which auto-completes: start container, generate config, and deploy:
Or step by step for inspection at each stage:
To build locally instead of pulling from Docker Hub:
Config
Customize image version and port mappings via .env:
Port Mapping:
| Env Var | Default | Container | Description |
|---|---|---|---|
PIGSTY_VERSION |
v4.5.0 |
- | Current main source default; verify the remote tag separately |
PIGSTY_SSH_PORT |
2222 |
22 | SSH access port |
PIGSTY_HTTP_PORT |
8080 |
80 | Nginx HTTP port |
PIGSTY_HTTPS_PORT |
8443 |
443 | Nginx HTTPS port |
PIGSTY_PG_PORT |
5432 |
5432 | PostgreSQL port |
Override via env vars if defaults are occupied:
Commands
Pigsty Docker provides Makefile commands for container and image management.
Docker Compose
Recommended way to run:
Container Access
Image Build
Image Management
Cleanup
The current Makefile no longer provides a countdown prompt. After removing the container, make purge runs rm -rf -- ./data directly. Verify the current directory and target data first, and back it up when necessary.
Manual Run
If you prefer docker run over Docker Compose:
Or use Makefile’s make run:
How It Works
Pigsty Docker image is based on Debian 13 (Trixie) with systemd as init.
Service management inside container stays consistent with native Linux via systemctl.
Key features:
- systemd support: Full systemd for proper service management
- SSH access: Pre-configured SSH, root password is
pigsty - Privileged mode: Requires
--privilegedfor systemd - Data persistence: Via
/datavolume mount - Pre-installed: pig CLI + Ansible, Pigsty source initialized
Image build executes these init steps:
Running ./configure with -c docker applies the Docker-optimized config template:
- Uses
127.0.0.1as default IP - Tuned for container environment
FAQ
Container won’t start
Ensure Docker is properly installed with sufficient resources. On Docker Desktop, allocate at least 2GB RAM. Check for port conflicts on 2222, 8080, 8443, 5432.
Can’t access services
Web Portal and PostgreSQL only available after deployment. Ensure ./deploy.yml finished successfully.
Use make status to check service status.
Port conflicts
Override via .env or env vars:
Data persistence
Container data mounted to ./data. To wipe and start fresh:
macOS performance
On macOS with Docker Desktop, performance is worse than native Linux due to virtualization overhead. Expected—Docker deployment is for dev/testing. For production, use native Linux installation.
More
- Docker Hub: https://hub.docker.com/r/pgsty/pigsty
- Source Directory: https://github.com/pgsty/pigsty/tree/main/docker
- Quick Start: Native Linux Installation
- Offline Installation: Offline
- Production Deployment: Deployment Guide