Running Docker in Aleph Cloud Instances
Aleph Cloud instances support running Docker containers, allowing you to deploy containerized applications on decentralized infrastructure.
Prerequisites
- An Aleph Cloud instance (Ubuntu 22.04 recommended)
- SSH access to your instance
- Sufficient resources (recommended: 2+ vCPUs, 4GB+ RAM for typical Docker workloads)
Installing Docker
Connect to your instance via SSH and run the official Docker installation script:
curl -fsSL https://get.docker.com | shThis installs:
- Docker Engine
- Docker CLI
- Docker Compose plugin
- containerd
Verify the installation:
docker version
docker compose versionRunning Your First Container
Test that Docker works correctly:
docker run --rm hello-worldExample: Running a Web Application
Here's an example deploying a simple web service with Docker Compose:
# Create a project directory
mkdir ~/myapp && cd ~/myapp
# Create docker-compose.yml
cat > docker-compose.yml << 'EOF'
services:
web:
image: nginx:alpine
ports:
- "8080:80"
volumes:
- ./html:/usr/share/nginx/html:ro
restart: unless-stopped
EOF
# Create a simple HTML page
mkdir html
echo '<h1>Hello from Aleph Cloud!</h1>' > html/index.html
# Start the service
docker compose up -d
# Check it's running
curl localhost:8080Example: Running Multiple Services
Deploy a more complex stack with multiple containers:
# docker-compose.yml
services:
app:
image: python:3.11-slim
command: python -m http.server 8000
ports:
- "8000:8000"
restart: unless-stopped
redis:
image: redis:alpine
restart: unless-stopped
postgres:
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: mysecretpassword
volumes:
- pgdata:/var/lib/postgresql/data
restart: unless-stopped
volumes:
pgdata:Exposing Services Publicly
To make your containerized services accessible from the internet, you have several options:
1. Cloudflare Tunnel (Recommended for quick testing)
# Install cloudflared
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared
chmod +x /usr/local/bin/cloudflared
# Create a quick tunnel
cloudflared tunnel --url http://localhost:80802. Port Forwarding via Aleph
Use the Aleph Cloud console or CLI to configure port forwarding for your instance.
3. Custom Domain with Reverse Proxy
Set up nginx or Caddy as a reverse proxy with SSL:
# docker-compose.yml with Caddy reverse proxy
services:
caddy:
image: caddy:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
restart: unless-stopped
app:
image: your-app:latest
expose:
- "8000"
volumes:
caddy_data:Best Practices
Resource Management
Monitor container resource usage:
docker statsSet resource limits in your compose file:
services:
app:
image: your-app
deploy:
resources:
limits:
cpus: '0.5'
memory: 512MPersistent Data
Always use Docker volumes for persistent data:
volumes:
app_data:
services:
db:
image: postgres
volumes:
- app_data:/var/lib/postgresql/dataAuto-restart
Ensure containers restart after instance reboot:
services:
app:
restart: unless-stoppedLogging
Configure logging to prevent disk space issues:
services:
app:
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"Troubleshooting
Docker daemon not starting
Check the Docker service status:
systemctl status docker
journalctl -u dockerPermission denied errors
If running as non-root, add your user to the docker group:
sudo usermod -aG docker $USER
# Log out and back in for changes to take effectOut of disk space
Clean up unused resources:
docker system prune -aLimitations
- Nested virtualization: Running VMs inside Docker containers may not work depending on the instance type
- Network performance: Container networking adds minimal overhead
- Disk space: Plan for container images and volumes in your instance storage allocation
Next Steps
- Custom Images - Create your own instance images
- Payment Models - Understand pay-as-you-go pricing