Files
mines/rin/miner/REMOTE_DOCKER_README.md
2025-09-08 08:59:24 +03:00

263 lines
7.1 KiB
Markdown

# 🐳 Remote Docker Setup for RinHash Miner
This guide explains how to set up remote Docker access so you can build the RinHash miner from another machine without needing root SSH access every time.
## 🎯 Windows 11 Quick Start (Most Common)
If you're using **Windows 11** as your local machine, here's the fastest way to get started:
### Step 1: Install Prerequisites on Windows
1. **Install Docker Desktop:**
- Download: https://www.docker.com/products/docker-desktop
- Enable WSL 2 during installation
2. **Enable OpenSSH Client:**
- Settings → Apps → Optional features → Add "OpenSSH Client"
3. **Install VS Code:**
- Download: https://code.visualstudio.com/
- Install extensions: "Docker" and "Remote SSH"
### Step 2: Setup Remote Connection
```powershell
# PowerShell (recommended for Windows):
ssh -L localhost:2375:/var/run/docker.sock user@linux-build-machine-ip
$env:DOCKER_HOST = "tcp://localhost:2375"
# Test connection:
docker run --rm cpuminer-windows-builder echo "Remote Docker working!"
```
### Step 3: Build Remotely
```powershell
# Now you can run builds from your Windows machine:
docker run --rm -v "${PWD}:/work" -v "${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows-smart.sh"
```
### Step 4: VS Code Integration (Optional)
1. **Connect to Linux machine:**
- `Ctrl+Shift+P` → "Remote-SSH: Connect to Host"
- Enter: `ssh user@linux-build-machine-ip`
2. **Run builds from VS Code:**
- Open Command Palette: `Ctrl+Shift+P`
- Select: "Tasks: Run Task"
- Choose: "Build Windows CPU Miner (Smart)"
That's it! You're now building remotely from Windows 11! 🚀
## Quick Setup (Recommended)
### On the Build Machine (where Docker runs):
```bash
cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner
./setup-remote-docker.sh
```
This script will:
- ✅ Add your user to the docker group
- ✅ Enable and start Docker service
- ✅ Test Docker access
- ✅ Provide connection instructions
### On Your Local Machine:
#### Option 1: SSH Port Forwarding (Most Secure)
**For Windows 11:**
```powershell
# PowerShell (recommended):
ssh -L localhost:2375:/var/run/docker.sock user@build-machine-ip
$env:DOCKER_HOST = "tcp://localhost:2375"
# Command Prompt:
ssh -L localhost:2375:/var/run/docker.sock user@build-machine-ip
set DOCKER_HOST=tcp://localhost:2375
```
**For Linux/Mac:**
```bash
# Forward Docker socket through SSH
ssh -L localhost:2375:/var/run/docker.sock user@build-machine-ip
# Set Docker to use remote host
export DOCKER_HOST=tcp://localhost:2375
```
**Test connection (all platforms):**
```bash
docker ps
docker run --rm cpuminer-windows-builder echo "Remote Docker working!"
```
#### Option 2: Docker Contexts
**For Windows 11:**
```powershell
# PowerShell:
docker context create build-server --docker "host=ssh://user@build-machine-ip"
docker context use build-server
docker ps
# Command Prompt:
docker context create build-server --docker "host=ssh://user@build-machine-ip"
docker context use build-server
docker ps
```
**For Linux/Mac:**
```bash
# Create context for remote machine
docker context create build-server --docker "host=ssh://user@build-machine-ip"
# Use the remote context
docker context use build-server
# All docker commands now work remotely
docker ps
```
**Benefits:**
- ✅ Automatic SSH key management
- ✅ No manual port forwarding needed
- ✅ Clean context switching between local and remote
#### Option 3: VS Code Integration (Windows 11)
1. **Install VS Code on Windows:**
- Download: https://code.visualstudio.com/
- Install extensions:
- Docker (Microsoft)
- Remote SSH (Microsoft)
- Remote Development (Microsoft)
2. **Connect to Linux build machine:**
- `Ctrl+Shift+P` → "Remote-SSH: Connect to Host"
- Enter: `ssh user@build-machine-ip`
- VS Code will open a new window connected to the Linux machine
3. **Use VS Code Docker panel:**
- View containers, images, and networks on remote machine
- Manage remote Docker from VS Code interface
- Run builds with one click
4. **Run builds from VS Code:**
- Open Command Palette: `Ctrl+Shift+P`
- Select: "Tasks: Run Task"
- Choose: "Build Windows CPU Miner (Smart)"
- Build runs directly on the Linux machine!
**Benefits:**
- ✅ Full IDE integration
- ✅ Remote development environment
- ✅ Docker management from VS Code
- ✅ One-click builds
## Build Commands
Once connected, you can run builds remotely from your Windows machine:
**PowerShell (Windows 11):**
```powershell
# Smart build (recommended)
docker run --rm -v "${PWD}:/work" -v "${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows-smart.sh"
# Manual build
docker run --rm -v "${PWD}:/work" -v "${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows.sh"
# Clean build
docker run --rm -v "${PWD}:/work" -v "${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && make clean"
```
**Command Prompt (Windows 11):**
```cmd
REM Smart build (recommended)
docker run --rm -v "%CD%:/work" -v "%CD%/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows-smart.sh"
REM Manual build
docker run --rm -v "%CD%:/work" -v "%CD%/build/win:/output" cpuminer-windows-builder bash -c "cd /work && ./build-windows.sh"
REM Clean build
docker run --rm -v "%CD%:/work" -v "%CD%/build/win:/output" cpuminer-windows-builder bash -c "cd /work && make clean"
```
**Linux/Mac (original):**
```bash
# Smart build (recommended)
./build-windows-smart.sh
# Manual build
./build-windows.sh
# Clean build
./build-clean.sh
```
## Security Notes
- ✅ SSH tunneling provides encrypted connection
- ✅ No need to expose Docker API publicly
- ✅ All communication goes through secure SSH
- ✅ Use VPN for additional security if needed
## Troubleshooting
### Permission Denied
```bash
# If you get permission errors, try:
newgrp docker
# or logout and login again
```
### Connection Refused
```bash
# Check if Docker is running on build machine:
ssh user@build-machine sudo systemctl status docker
# Start Docker if needed:
ssh user@build-machine sudo systemctl start docker
```
### VS Code Issues
- Make sure Remote SSH extension is installed
- Check that SSH key authentication is set up
- Verify firewall allows SSH connections
## Alternative Methods
### Docker Remote API (Advanced)
For direct TCP access to Docker API (less secure, requires firewall configuration):
```bash
# On build machine (as root):
sudo systemctl edit docker
# Add: ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376
sudo systemctl restart docker
```
```bash
# On local machine:
export DOCKER_HOST=tcp://build-machine-ip:2376
```
### Docker Desktop (Windows/Mac)
If you have Docker Desktop on your local machine:
1. Settings → General → Enable "Expose daemon on tcp://localhost:2375"
2. Use SSH port forwarding as described above
## Performance Tips
- Use fast network connection between machines
- Consider using `--mount` instead of `-v` for better performance
- Use Docker contexts to easily switch between local and remote
## Need Help?
Check the main [BUILD_GUIDE.md](BUILD_GUIDE.md) for detailed instructions and troubleshooting.