Docker
Docker Containers
Manage Docker containers with SkyPort
Docker Container Management
SkyPort provides a powerful interface for managing Docker containers.
List Containers
View all containers on your system:
# List running containers
skyport docker ps
# List all containers (including stopped)
skyport docker ps -a
# Show container details
skyport docker ps --format json
skyport docker ps --format table
Running Containers
Start a New Container
# Simple container
skyport docker run -d nginx:latest
# Named container with port mapping
skyport docker run -d \
--name webserver \
-p 8000:80 \
nginx:latest
# Container with environment variables
skyport docker run -d \
--name app \
-e NODE_ENV=production \
-e PORT=3000 \
node-app:latest
# Container with volume mounting
skyport docker run -d \
--name db \
-v postgres-data:/var/lib/postgresql/data \
postgres:15
# Container with resource limits
skyport docker run -d \
--name heavy-app \
--memory="512m" \
--cpus="1" \
heavy-app:latest
# Container with health check
skyport docker run -d \
--name webapp \
--health-cmd="curl -f http://localhost/ || exit 1" \
--health-interval=30s \
--health-timeout=5s \
--health-retries=3 \
webapp:latest
Container Operations
View Logs
# View logs
skyport docker logs container-name
# Follow logs (tail -f style)
skyport docker logs container-name -f
# View last 100 lines
skyport docker logs container-name --tail 100
# View logs with timestamps
skyport docker logs container-name --timestamps
Manage Containers
# Start container
skyport docker start container-name
# Stop container
skyport docker stop container-name
# Restart container
skyport docker restart container-name
# Pause container
skyport docker pause container-name
# Unpause container
skyport docker unpause container-name
# Remove container
skyport docker rm container-name
# Remove with force
skyport docker rm -f container-name
Container Information
# View container details
skyport docker inspect container-name
# View container stats
skyport docker stats container-name
# View running processes in container
skyport docker top container-name
Execute Commands
# Execute command in container
skyport docker exec container-name ls -la
# Interactive terminal session
skyport docker exec -it container-name /bin/bash
# Run with environment
skyport docker exec -e VAR=value container-name command
Images
List Images
# List all images
skyport docker images
# List with size
skyport docker images --format table
Pull Images
# Pull from Docker Hub
skyport docker pull nginx:latest
# Pull from specific registry
skyport docker pull registry.example.com/app:latest
Build Images
# Build from Dockerfile
skyport docker build -t my-app:1.0.0 .
# Build with build args
skyport docker build -t my-app:1.0.0 \
--build-arg VERSION=1.0.0 \
--build-arg NODE_ENV=production \
.
# Build and push
skyport docker build -t my-app:1.0.0 .
skyport docker push my-app:1.0.0
Remove Images
# Remove image
skyport docker rmi image-name:tag
# Remove unused images
skyport docker image prune
# Remove all images
skyport docker rmi -a
Volumes
List Volumes
# List all volumes
skyport docker volume ls
Create Volumes
# Create named volume
skyport docker volume create my-data
# Create and use volume
skyport docker run -d \
-v my-data:/app/data \
my-app:latest
Manage Volumes
# View volume details
skyport docker volume inspect my-data
# Remove volume
skyport docker volume rm my-data
# Remove unused volumes
skyport docker volume prune
Networks
List Networks
# List networks
skyport docker network ls
Create Networks
# Create bridge network
skyport docker network create my-network
# Create with options
skyport docker network create \
--driver bridge \
--subnet 172.20.0.0/16 \
my-network
Connect Containers
# Run container on network
skyport docker run -d \
--network my-network \
--name app \
app:latest
# Connect existing container
skyport docker network connect my-network existing-container
# Disconnect container
skyport docker network disconnect my-network container-name
Common Patterns
Nginx Reverse Proxy
# Pull Nginx
skyport docker pull nginx:latest
# Run Nginx
skyport docker run -d \
--name nginx \
-p 80:80 \
-p 443:443 \
-v /etc/nginx/conf.d:/etc/nginx/conf.d \
-v /etc/letsencrypt:/etc/letsencrypt \
nginx:latest
PostgreSQL Database
# Create volume for data persistence
skyport docker volume create postgres-data
# Run PostgreSQL
skyport docker run -d \
--name postgres \
-e POSTGRES_PASSWORD=secure_password \
-e POSTGRES_DB=myapp \
-v postgres-data:/var/lib/postgresql/data \
-p 5432:5432 \
postgres:15
Node.js Application
# Build image
skyport docker build -t my-app:1.0.0 .
# Run with environment
skyport docker run -d \
--name my-app \
-e NODE_ENV=production \
-e DATABASE_URL=postgresql://user:pass@postgres:5432/db \
-p 3000:3000 \
--restart unless-stopped \
my-app:1.0.0
Multi-container Setup
# Create network
skyport docker network create my-app-network
# Start database
skyport docker run -d \
--name postgres \
--network my-app-network \
-e POSTGRES_PASSWORD=pass \
-v postgres-data:/var/lib/postgresql/data \
postgres:15
# Start Redis
skyport docker run -d \
--name redis \
--network my-app-network \
redis:latest
# Start application
skyport docker run -d \
--name app \
--network my-app-network \
-e DATABASE_URL=postgresql://postgres:pass@postgres:5432/postgres \
-e REDIS_URL=redis://redis:6379 \
-p 3000:3000 \
app:latest
Best Practices
- Always mount volumes for persistent data
- Use health checks for critical applications
- Set resource limits to prevent system overload
- Use named volumes instead of bind mounts when possible
- Enable automatic restart policies
- Use environment variables for configuration
- Don't run as root in containers when possible
Next: Docker Images | Docker Compose
