| name | docker |
| description | Container operations - build, deploy, compose, logs, debugging |
Docker Skill
Container operations skill for building, deploying, and managing Docker containers across different platforms.
When to Use
Invoke this skill when:
- Building Docker images
- Managing docker-compose setups
- Deploying containers to Coolify or Hostinger
- Debugging container issues
- Viewing logs
Part 1: Building Images
Basic Build
# Build with default Dockerfile
docker build -t myapp:latest .
# Build with specific Dockerfile
docker build -f Dockerfile.prod -t myapp:prod .
# Build with build args
docker build --build-arg NODE_ENV=production -t myapp:prod .
# Multi-platform build
docker buildx build --platform linux/amd64,linux/arm64 -t myapp:latest .
Optimized Dockerfile Pattern
# Stage 1: Dependencies
FROM node:20-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
# Stage 2: Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Stage 3: Production
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/dist ./dist
COPY --from=deps /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "dist/index.js"]
Part 2: Docker Compose
Development Setup
# docker-compose.yml
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
environment:
- DATABASE_URL=postgresql://user:pass@db:5432/mydb
depends_on:
- db
db:
image: postgres:15-alpine
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: pass
POSTGRES_DB: mydb
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
Common Commands
# Start services
docker-compose up -d
# Stop services
docker-compose down
# View logs
docker-compose logs -f app
# Rebuild and restart
docker-compose up -d --build
# Run one-off command
docker-compose exec app npm run migrate
# Scale service
docker-compose up -d --scale worker=3
Part 3: Deployment to Coolify
Create Docker Compose App
# Create from docker-compose
mycli run coolify/apps/create-compose \
--project_uuid "project-uuid" \
--server_uuid "server-uuid" \
--docker_compose_raw "$(cat docker-compose.prod.yml)"
Create from Dockerfile
# Create from GitHub repo with Dockerfile
mycli run coolify/apps/create-dockerfile \
--project_uuid "project-uuid" \
--server_uuid "server-uuid" \
--repository "owner/repo" \
--branch "main"
Deploy Updates
# Trigger deployment
mycli run coolify/deployments/deploy --uuid "app-uuid"
# Deploy specific tag
mycli run coolify/deployments/deploy-by-tag \
--uuid "app-uuid" \
--tag "v1.2.3"
Part 4: Deployment to Hostinger
Direct Docker Deployment
# List Docker projects
mycli run hostinger/vps/docker/list --vm_id "vm-id"
# Update project
mycli run hostinger/vps/docker/update \
--vm_id "vm-id" \
--project_id "project-id" \
--compose_file "$(cat docker-compose.yml)"
# Restart after update
mycli run hostinger/vps/docker/restart \
--vm_id "vm-id" \
--project_id "project-id"
Part 5: Debugging
Container Logs
# View logs
docker logs mycontainer
# Follow logs
docker logs -f mycontainer
# Last N lines
docker logs --tail 100 mycontainer
# With timestamps
docker logs -t mycontainer
Remote Logs (Coolify)
# Get deployment logs
mycli run coolify/deployments/get --uuid "deployment-uuid"
Remote Logs (Hostinger)
# Get project logs
mycli run hostinger/vps/docker/logs \
--vm_id "vm-id" \
--project_id "project-id"
Interactive Shell
# Exec into running container
docker exec -it mycontainer /bin/sh
# As root
docker exec -u root -it mycontainer /bin/sh
Inspect Container
# Full inspection
docker inspect mycontainer
# Get IP address
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mycontainer
# Get mounted volumes
docker inspect -f '{{json .Mounts}}' mycontainer | jq
Resource Usage
# Live stats
docker stats
# Specific container
docker stats mycontainer
Part 6: Common Patterns
Health Checks
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
Environment Files
# Use .env file
docker-compose --env-file .env.production up -d
# Pass individual vars
docker run -e API_KEY="secret" myapp
Volume Patterns
# Named volume (persistent)
volumes:
- postgres_data:/var/lib/postgresql/data
# Bind mount (development)
volumes:
- ./src:/app/src
# Anonymous volume (node_modules)
volumes:
- /app/node_modules
Network Patterns
# Internal network
networks:
internal:
driver: bridge
services:
app:
networks:
- internal
db:
networks:
- internal
Troubleshooting
Container Won't Start
# Check logs
docker logs mycontainer
# Check exit code
docker inspect -f '{{.State.ExitCode}}' mycontainer
# Run interactively to see errors
docker run -it myapp /bin/sh
Port Already in Use
# Find what's using the port
lsof -i :3000
# Use different port
docker run -p 3001:3000 myapp
Out of Disk Space
# Clean up unused resources
docker system prune -a
# Clean volumes too
docker system prune -a --volumes
Network Issues
# List networks
docker network ls
# Inspect network
docker network inspect bridge
# Check container connectivity
docker exec mycontainer ping other-container