Hero Background Light
DevOps CodeShelf Guide: Docker, Git & CI Commands | SRE Productivity Tool

DevOps Daily Driver: Git, Docker, and CI Snippets in CodeShelf

How SREs and DevOps engineers use CodeShelf to centralize recurring commands and workflows for reliable operations and faster incident response.

DevOps Daily Driver: Git, Docker, and CI Snippets in CodeShelf

DevOps engineers and SREs juggle dozens of commands daily—Docker maintenance, Git operations, Kubernetes debugging, CI pipeline fixes, and incident response procedures. Most of these commands are complex, critical, and infrequently used enough to forget the exact syntax.

The typical DevOps workflow involves:

  • Googling command syntax under pressure
  • Digging through old terminal history
  • Copy-pasting from team wikis that may be outdated
  • Asking teammates for “that Docker command” again
  • Making syntax errors during critical operations

CodeShelf eliminates this friction by putting your essential DevOps commands one click away in the macOS menu bar. Here’s how to build a comprehensive operations toolkit that saves time and reduces errors.

The Cost of Command Hunting in DevOps

Time Lost to Context Switching

Consider a typical incident response:

  1. Alert fires: Service degraded, CPU spiking
  2. Context switch #1: Find terminal, ssh to server
  3. Context switch #2: Google “docker container memory usage command”
  4. Context switch #3: Switch to wiki to find logging commands
  5. Context switch #4: Slack teammate for Kubernetes debugging syntax
  6. Finally: Start actual diagnosis after 3-5 minutes of setup

With CodeShelf, step 2 becomes: “Open menu bar, copy diagnostic commands, paste to terminal.” Total setup time: 15 seconds.

Error Risk in Critical Operations

DevOps commands often have significant consequences:

  • Wrong Docker flags can stop production services
  • Incorrect Kubernetes selectors can affect the wrong pods
  • Git mistakes can lose work or break deployment branches
  • Database commands can corrupt data if parameters are wrong

Having the exact, tested commands readily available reduces operational risk.

Essential DevOps Categories in CodeShelf

1. Docker & Container Management

Container Inspection and Debugging

Terminal window
# Show running containers with resource usage
docker stats --no-stream
# Get detailed container info
docker inspect <container_id> | jq '.[]'
# Follow logs for specific container
docker logs -f --tail=100 <container_name>
# Execute shell in running container
docker exec -it <container_name> /bin/bash

System Maintenance and Cleanup

Terminal window
# Clean up unused containers, networks, images, and build cache
docker system prune -a --volumes
# Show disk usage by Docker
docker system df
# Remove dangling images
docker image prune
# Remove stopped containers
docker container prune

Production Deployment Commands

Terminal window
# Pull latest image and restart service
docker-compose pull web
docker-compose up -d --no-deps web
# Rolling update with zero downtime
docker service update --image myapp:latest myapp_web
# Scale service replicas
docker service scale myapp_web=5

2. Git Operations for Infrastructure

Branch Management for Deployments

Terminal window
# Create and switch to hotfix branch
git checkout -b hotfix/critical-fix-$(date +%Y%m%d)
# Safe merge with no fast-forward
git merge --no-ff feature-branch
# Push new branch with upstream tracking
git push -u origin hotfix/critical-fix-$(date +%Y%m%d)

Deployment and Release Tags

Terminal window
# Tag current commit for release
git tag -a v$(date +%Y.%m.%d) -m "Production release $(date +%Y-%m-%d)"
# Push tags to remote
git push origin --tags
# List recent tags
git tag -l --sort=-version:refname | head -10

Repository Maintenance

Terminal window
# Clean up merged branches (keep main/develop/staging)
git branch --merged | grep -v "\\*\\|main\\|master\\|develop\\|staging" | xargs -n 1 git branch -d
# Fetch and prune deleted remote branches
git fetch --all --prune
# Reset hard to match remote (destructive - use carefully)
git reset --hard origin/$(git branch --show-current)

3. Kubernetes Operations

Pod and Service Debugging

Terminal window
# Get pod logs with previous container logs
kubectl logs -f pod-name --previous
# Execute shell in pod
kubectl exec -it pod-name -- /bin/bash
# Port forward for local debugging
kubectl port-forward pod-name 8080:80
# Get pod details and events
kubectl describe pod pod-name

Cluster Resource Monitoring

Terminal window
# Show resource usage across nodes
kubectl top nodes
# Show pod resource usage in namespace
kubectl top pods -n production --sort-by=cpu
# Get all resources in namespace
kubectl get all -n production
# Show cluster events (recent first)
kubectl get events --sort-by=.metadata.creationTimestamp

Deployment Management

Terminal window
# Rolling restart of deployment
kubectl rollout restart deployment/app-name -n production
# Check rollout status
kubectl rollout status deployment/app-name -n production
# Rollback to previous version
kubectl rollout undo deployment/app-name -n production
# Scale deployment
kubectl scale deployment/app-name --replicas=5 -n production

4. System Monitoring and Performance

Server Health Checks

Terminal window
# System resource overview
htop -d 10
# Disk usage by directory
du -sh /* 2>/dev/null | sort -hr | head -20
# Memory usage breakdown
free -h && echo "" && ps aux --sort=-%mem | head -10
# Network connection monitoring
netstat -tuln | grep LISTEN

Log Analysis Commands

Terminal window
# Follow system logs
journalctl -f -u service-name
# Search logs for error patterns
grep -i "error\\|exception\\|failed" /var/log/app.log | tail -20
# Count log entries by hour
awk '{print $4}' /var/log/access.log | cut -d: -f1-2 | uniq -c
# Find large log files
find /var/log -name "*.log" -type f -exec du -sh {} \\; | sort -hr | head -10

5. Database Operations

PostgreSQL Maintenance

-- Check database connections and activity
SELECT datname, numbackends, xact_commit, xact_rollback
FROM pg_stat_database
WHERE datname NOT IN ('template0', 'template1', 'postgres');
-- Find slow queries
SELECT query, mean_exec_time, calls, total_exec_time
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 10;
-- Check table sizes
SELECT schemaname, tablename,
pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) as size
FROM pg_tables
ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC
LIMIT 10;

Database Backup and Restore

Terminal window
# Create timestamped backup
pg_dump -U postgres -h localhost database_name > backup_$(date +%Y%m%d_%H%M%S).sql
# Restore from backup
psql -U postgres -h localhost -d database_name < backup_file.sql
# Create compressed backup
pg_dump -U postgres -h localhost database_name | gzip > backup_$(date +%Y%m%d_%H%M%S).sql.gz

Multi-Step Incident Response Procedures

Performance Issue Investigation

Create a multi-step snippet for systematic performance debugging:

Step 1: System Overview

Terminal window
# Check overall system health
top -bn1 | head -20
df -h
free -m

Step 2: Application Layer

Terminal window
# Check application containers
docker stats --no-stream
kubectl top pods -n production --sort-by=cpu

Step 3: Database Performance

-- Check for blocking queries
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS current_statement_in_blocking_process
FROM pg_catalog.pg_locks blocked_locks
JOIN pg_catalog.pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pid
JOIN pg_catalog.pg_locks blocking_locks ON blocking_locks.locktype = blocked_locks.locktype
JOIN pg_catalog.pg_stat_activity blocking_activity ON blocking_activity.pid = blocking_locks.pid
WHERE NOT blocked_locks.GRANTED;

Step 4: Network and Load Balancer

Terminal window
# Check load balancer health
curl -I https://api.example.com/health
# Check response times
curl -w "@curl-format.txt" -o /dev/null -s https://api.example.com/health

Deployment Rollback Procedure

Step 1: Identify Current Version

Terminal window
# Get current deployment image
kubectl describe deployment/app-name -n production | grep Image

Step 2: Check Rollback Targets

Terminal window
# List recent deployment revisions
kubectl rollout history deployment/app-name -n production

Step 3: Execute Rollback

Terminal window
# Rollback to previous version
kubectl rollout undo deployment/app-name -n production

Step 4: Verify Rollback

Terminal window
# Check rollout status
kubectl rollout status deployment/app-name -n production
# Verify pods are healthy
kubectl get pods -n production -l app=app-name

Step 5: Test Application

Terminal window
# Run health check
curl -f https://api.example.com/health || echo "Health check failed"

Organizing Your DevOps Snippet Library

Hierarchical Structure

📁 Infrastructure
📁 Docker
⭐ Container Health Check
⭐ System Cleanup
📝 Multi-step: Deploy New Version
📁 Kubernetes
⭐ Pod Debugging Commands
⭐ Resource Monitoring
📝 Multi-step: Rolling Update
📁 Git Operations
⭐ Deployment Branches
⭐ Release Tags
📝 Multi-step: Hotfix Process
📁 Monitoring
⭐ System Health Overview
⭐ Log Analysis
📝 Multi-step: Performance Investigation
📁 Database
⭐ Performance Queries
⭐ Backup Commands
📝 Multi-step: Maintenance Window
📁 Incident Response
📝 Multi-step: Service Degradation
📝 Multi-step: Security Incident
📝 Multi-step: Data Recovery

Favorites Strategy for DevOps

Mark as favorites based on urgency and frequency:

Daily Operations:

  • Docker container status
  • Kubernetes pod monitoring
  • System resource checks
  • Log tailing commands

Emergency Procedures:

  • Incident response multi-step workflows
  • Service restart commands
  • Database connection checks
  • Load balancer health verification

Environment-Specific Organization

Create separate categories or use environment prefixes:

  • Production Commands (marked with ⚠️ for extra caution)
  • Staging Operations
  • Development Utilities
  • Local Testing

Measuring DevOps Productivity Impact

Incident Response Time

  • Before CodeShelf: 3-5 minutes finding and verifying commands
  • After CodeShelf: 15-30 seconds accessing proven procedures
  • Improvement: 80-90% faster time to effective action

Operational Error Rate

  • Before: 5-10% error rate on complex operations under pressure
  • After: <1% error rate with tested, exact commands
  • Improvement: 90% reduction in operational mistakes

Knowledge Transfer

  • Before: New team members take weeks to learn all the commands
  • After: Comprehensive snippet library provides immediate access to team knowledge
  • Improvement: 70% faster onboarding for operations tasks

Team Adoption Best Practices

1. Start with Incident Response

Build multi-step procedures for your most common incidents first. When the next incident occurs and resolution is 5x faster, the team will immediately see the value.

2. Share Critical Commands

Use CodeShelf’s export/import feature (Pro) to share your snippet library with team members. This ensures everyone has access to the same tested, reliable commands.

3. Version Control Your Snippets

Export your snippet library regularly and commit it to a team repository. This creates a backup and allows you to track changes to operational procedures over time.

4. Create Command Documentation

Use the multi-step format to document not just the commands, but also the context and expected output. This helps team members understand when and why to use specific procedures.

Security Considerations

Sensitive Information Handling

  • Don’t store passwords in snippets—use environment variables or keychain references
  • Use placeholder variables for server names and sensitive parameters
  • Mark sensitive snippets with clear warnings about production usage
  • Export libraries without sensitive data when sharing with team members

Production Safety

Terminal window
# Use confirmation prompts for destructive operations
echo "About to delete unused Docker containers. Press Enter to continue or Ctrl+C to cancel"
read
docker container prune -f

Conclusion: Operations Excellence Through Organization

DevOps success depends on reliable execution of complex procedures under pressure. CodeShelf transforms scattered command knowledge into an organized, instantly-accessible toolkit that reduces errors and accelerates response times.

The key is building your library incrementally:

  1. Start with daily commands you find yourself googling repeatedly
  2. Add multi-step procedures for your most critical operations
  3. Share with your team to standardize operational practices
  4. Refine and expand based on operational needs

Ready to eliminate command hunting? Download CodeShelf and build your comprehensive DevOps command library today.


CodeShelf is available for macOS 13 Ventura or later. Team sharing features require the Pro upgrade for export/import functionality.