# Database

**🟡 Media Service**

## 📋 Service Overview

| Property | Value |
|----------|-------|
| **Service Name** | database |
| **Host** | raspberry-pi-5-vish |
| **Category** | Media |
| **Difficulty** | 🟡 |
| **Docker Image** | `ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0` |
| **Compose File** | `raspberry-pi-5-vish/immich/docker-compose.yml` |
| **Directory** | `raspberry-pi-5-vish/immich` |

## 🎯 Purpose

database is a media management and streaming service that helps organize and serve your digital media content.

## 🚀 Quick Start

### Prerequisites
- Docker and Docker Compose installed
- Basic understanding of REDACTED_APP_PASSWORD
- Access to the host system (raspberry-pi-5-vish)

### Deployment
```bash
# Navigate to service directory
cd raspberry-pi-5-vish/immich

# Start the service
docker-compose up -d

# Check service status
docker-compose ps

# View logs
docker-compose logs -f database
```

## 🔧 Configuration

### Docker Compose Configuration
```yaml
container_name: immich_postgres
environment:
  POSTGRES_DB: ${DB_DATABASE_NAME}
  POSTGRES_INITDB_ARGS: --data-checksums
  POSTGRES_PASSWORD: "REDACTED_PASSWORD"
  POSTGRES_USER: ${DB_USERNAME}
image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0
restart: unless-stopped
shm_size: 128mb
volumes:
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data

```

### Environment Variables
| Variable | Value | Description |
|----------|-------|-------------|
| `POSTGRES_PASSWORD` | `***MASKED***` | PostgreSQL password |
| `POSTGRES_USER` | `${DB_USERNAME}` | Configuration variable |
| `POSTGRES_DB` | `${DB_DATABASE_NAME}` | Configuration variable |
| `POSTGRES_INITDB_ARGS` | `--data-checksums` | Configuration variable |


### Port Mappings
No ports exposed.

### Volume Mappings
| Host Path | Container Path | Type | Purpose |
|-----------|----------------|------|----------|
| `${DB_DATA_LOCATION}` | `/var/lib/postgresql/data` | volume | Application data |


## 🌐 Access Information

This service does not expose any web interfaces.

## 🔒 Security Considerations

- ⚠️ Consider adding security options (no-new-privileges)
- ⚠️ Consider running as non-root user

## 📊 Resource Requirements

No resource limits configured

### Recommended Resources
- **Minimum RAM**: 512MB
- **Recommended RAM**: 1GB+
- **CPU**: 1 core minimum
- **Storage**: Varies by usage

### Resource Monitoring
Monitor resource usage with:
```bash
docker stats
```

## 🔍 Health Monitoring

⚠️ No health check configured
Consider adding a health check:
```yaml
healthcheck:
  test: ["CMD", "curl", "-f", "http://localhost:PORT/health"]
  interval: 30s
  timeout: 10s
  retries: 3
```

### Manual Health Checks
```bash
# Check container health
docker inspect --format='{{.State.Health.Status}}' CONTAINER_NAME

# View health check logs
docker inspect --format='{{range .State.Health.Log}}{{.Output}}{{end}}' CONTAINER_NAME
```

## 🚨 Troubleshooting

### Common Issues
**Service won't start**
- Check Docker logs: `docker-compose logs service-name`
- Verify port availability: `netstat -tulpn | grep PORT`
- Check file permissions on mounted volumes

**Can't access web interface**
- Verify service is running: `docker-compose ps`
- Check firewall settings
- Confirm correct port mapping

**Performance issues**
- Monitor resource usage: `docker stats`
- Check available disk space: `df -h`
- Review service logs for errors

**Media not showing**
- Check media file permissions
- Verify volume mounts are correct
- Scan media library manually

### Useful Commands
```bash
# Check service status
docker-compose ps

# View real-time logs
docker-compose logs -f database

# Restart service
docker-compose restart database

# Update service
docker-compose pull database
docker-compose up -d database

# Access service shell
docker-compose exec database /bin/bash
# or
docker-compose exec database /bin/sh
```

## 📚 Additional Resources

- **Official Documentation**: Check the official docs for database
- **Docker Hub**: [ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0](https://hub.docker.com/r/ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0)
- **Community Forums**: Search for community discussions and solutions
- **GitHub Issues**: Check the project's GitHub for known issues

## 🔗 Related Services

Services REDACTED_APP_PASSWORD database:
- Plex
- Jellyfin
- Radarr
- Sonarr
- Bazarr

---

*This documentation is auto-generated from the Docker Compose configuration. For the most up-to-date information, refer to the official documentation and the actual compose file.*

**Last Updated**: 2025-11-17  
**Configuration Source**: `raspberry-pi-5-vish/immich/docker-compose.yml`
