143 lines
3.5 KiB
Markdown
143 lines
3.5 KiB
Markdown
# 🚀 Quick Reference - Docker Bind Mounts
|
|
|
|
## Setup (First Time Only)
|
|
|
|
```powershell
|
|
# Run the setup script
|
|
.\setup-bind-mounts.ps1 -GrantFullPermissions
|
|
|
|
# Or manually create directories
|
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Faces"
|
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Storage"
|
|
New-Item -ItemType Directory -Force -Path "D:\AppData\Logs"
|
|
|
|
# Grant permissions
|
|
icacls "D:\AppData\Faces" /grant Everyone:F /T
|
|
icacls "D:\AppData\Storage" /grant Everyone:F /T
|
|
icacls "D:\AppData\Logs" /grant Everyone:F /T
|
|
```
|
|
|
|
## Daily Operations
|
|
|
|
### Start Container
|
|
```powershell
|
|
docker-compose up -d
|
|
```
|
|
|
|
### Stop Container
|
|
```powershell
|
|
docker-compose down
|
|
```
|
|
|
|
### View Logs
|
|
```powershell
|
|
docker-compose logs -f
|
|
# Or check the host directory
|
|
Get-Content D:\AppData\Logs\gozareshgir_log.txt -Tail 50 -Wait
|
|
```
|
|
|
|
### Restart Container
|
|
```powershell
|
|
docker-compose restart
|
|
```
|
|
|
|
### Rebuild & Restart
|
|
```powershell
|
|
docker-compose down
|
|
docker-compose build --no-cache
|
|
docker-compose up -d
|
|
```
|
|
|
|
## Verification Commands
|
|
|
|
### Check if directories are mounted
|
|
```powershell
|
|
docker exec gozareshgir-servicehost ls -la /app
|
|
```
|
|
|
|
### Test write access from container
|
|
```powershell
|
|
docker exec gozareshgir-servicehost sh -c "echo 'test' > /app/Storage/test.txt"
|
|
Get-Content D:\AppData\Storage\test.txt
|
|
Remove-Item D:\AppData\Storage\test.txt
|
|
```
|
|
|
|
### View mount details
|
|
```powershell
|
|
docker inspect gozareshgir-servicehost --format='{{json .Mounts}}' | ConvertFrom-Json | Format-List
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Permission Issues
|
|
```powershell
|
|
# Fix permissions
|
|
icacls "D:\AppData\Faces" /grant Everyone:F /T
|
|
icacls "D:\AppData\Storage" /grant Everyone:F /T
|
|
icacls "D:\AppData\Logs" /grant Everyone:F /T
|
|
```
|
|
|
|
### Check Disk Space
|
|
```powershell
|
|
Get-PSDrive D | Select-Object Used,Free,@{Name="FreeGB";Expression={[math]::Round($_.Free/1GB,2)}}
|
|
```
|
|
|
|
### View Container Logs
|
|
```powershell
|
|
docker logs gozareshgir-servicehost --tail 100 -f
|
|
```
|
|
|
|
## Backup
|
|
|
|
### Manual Backup
|
|
```powershell
|
|
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
|
|
robocopy "D:\AppData" "D:\Backups\AppData_$timestamp" /MIR /Z
|
|
```
|
|
|
|
### Quick Backup (no mirroring)
|
|
```powershell
|
|
robocopy "D:\AppData" "D:\Backups\AppData" /E /Z
|
|
```
|
|
|
|
## Path Mapping Reference
|
|
|
|
| Container Path | Windows Host Path | Purpose |
|
|
|-----------------|-----------------------|----------------------------|
|
|
| `/app/Faces` | `D:\AppData\Faces` | Face recognition data |
|
|
| `/app/Storage` | `D:\AppData\Storage` | Uploaded files/documents |
|
|
| `/app/Logs` | `D:\AppData\Logs` | Application logs |
|
|
| `/app/certs` | `.\ServiceHost\certs` | SSL certificates (readonly)|
|
|
|
|
## Important Notes
|
|
|
|
✅ **Data is persistent** - survives container removal and rebuilds
|
|
✅ **Direct access** - files can be accessed directly from Windows Explorer
|
|
✅ **Real-time sync** - changes in container appear on host immediately
|
|
⚠️ **Do not delete** - `D:\AppData\*` directories contain production data
|
|
⚠️ **Backup regularly** - set up scheduled backups for business continuity
|
|
|
|
## Docker Run Alternative
|
|
|
|
If not using docker-compose:
|
|
|
|
```powershell
|
|
docker run -d `
|
|
--name gozareshgir-servicehost `
|
|
-p 5003:80 `
|
|
-p 5004:443 `
|
|
-v "D:/AppData/Faces:/app/Faces" `
|
|
-v "D:/AppData/Storage:/app/Storage" `
|
|
-v "D:/AppData/Logs:/app/Logs" `
|
|
-v "${PWD}/ServiceHost/certs:/app/certs:ro" `
|
|
--env-file ./ServiceHost/.env `
|
|
--add-host=host.docker.internal:host-gateway `
|
|
--restart unless-stopped `
|
|
gozareshgir-servicehost:latest
|
|
```
|
|
|
|
---
|
|
|
|
📖 **Full documentation:** `DOCKER_BIND_MOUNTS_SETUP.md`
|
|
|