Quick Start with portracker using Docker Compose
mainTo deploy portracker quickly, create a docker-compose.yml file with the following configuration. Note that specific flags like pid: "host", cap_add, and security_opt are required for the application to detect system ports and access the host namespace.
Key requirements for successful deployment:
pid: "host": Required for port detection.cap_add:SYS_PTRACE(for Linux hosts to read/procentries) andSYS_ADMIN(required for Docker Desktop on MacOS).security_opt:apparmor:unconfinedis required for system ports.volumes: Mount a local directory to/datafor SQLite persistence and mount/var/run/docker.sockfor Docker service discovery.
services:
portracker:
image: mostafawahied/portracker:latest
container_name: portracker
restart: unless-stopped
pid: "host" # Required for port detection
# Required permissions for system ports service namespace access
cap_add:
- SYS_PTRACE # Linux hosts: read other PIDs' /proc entries
- SYS_ADMIN # Docker Desktop: allow namespace access for host ports (required for MacOS)
security_opt:
- apparmor:unconfined # Required for system ports
volumes:
# Required for data persistence
- ./portracker-data:/data
# Required for discovering services running in Docker
- /var/run/docker.sock:/var/run/docker.sock:ro
ports:
- "4999:4999"
# environment:
# Optional: For enhanced TrueNAS features
# - TRUENAS_API_KEY=your-api-key-here