Skip to main content

Containers API

List Containers

GET /api/v1/containers
Query Parameters:
  • host - Filter by host ID or name
  • status - Filter by status: running, stopped, paused
  • image - Filter by image name
Response:
{
  "containers": [
    {
      "id": "container_abc123",
      "docker_id": "a1b2c3d4e5f6",
      "name": "nginx-web",
      "image": "nginx:1.25",
      "status": "running",
      "host": "web-1",
      "cpu_percent": 2.5,
      "memory_mb": 64,
      "memory_limit_mb": 256,
      "memory_percent": 25,
      "network_in_mb": 125,
      "network_out_mb": 45,
      "ports": ["80:80", "443:443"],
      "created_at": "2024-01-10T08:00:00Z",
      "started_at": "2024-01-10T08:00:05Z"
    }
  ]
}

Get Container Details

GET /api/v1/containers/:id
Response:
{
  "id": "container_abc123",
  "docker_id": "a1b2c3d4e5f6",
  "name": "nginx-web",
  "image": "nginx:1.25",
  "status": "running",
  "host": {
    "id": "host_xyz",
    "name": "web-1"
  },
  "metrics": {
    "cpu_percent": 2.5,
    "memory_mb": 64,
    "memory_limit_mb": 256,
    "memory_percent": 25,
    "network_in_bytes": 131072000,
    "network_out_bytes": 47185920,
    "block_read_bytes": 1048576,
    "block_write_bytes": 524288,
    "pids": 5
  },
  "config": {
    "ports": ["80:80", "443:443"],
    "environment": ["NGINX_HOST=example.com"],
    "volumes": ["/data:/var/www:ro"],
    "labels": {
      "com.docker.compose.project": "myapp",
      "com.docker.compose.service": "web"
    }
  },
  "created_at": "2024-01-10T08:00:00Z",
  "started_at": "2024-01-10T08:00:05Z",
  "health_check": {
    "status": "healthy",
    "failing_streak": 0,
    "last_check": "2024-01-15T10:29:55Z"
  }
}

Get Container Metrics History

GET /api/v1/containers/:id/metrics
Query Parameters:
  • period - Time period: hour, day, week
  • resolution - Data resolution: minute, 5min, hour
Response:
{
  "container": "nginx-web",
  "period": "day",
  "resolution": "hour",
  "metrics": [
    {
      "timestamp": "2024-01-15T10:00:00Z",
      "cpu_percent": 2.5,
      "memory_mb": 64,
      "memory_percent": 25,
      "network_in_mb": 5.2,
      "network_out_mb": 1.8
    }
  ]
}

List Container Events

GET /api/v1/containers/events
Query Parameters:
  • host - Filter by host
  • container - Filter by container name
  • event - Filter by event type: start, stop, restart, die, oom
  • since - Events since timestamp
Response:
{
  "events": [
    {
      "id": "event_abc123",
      "container": "nginx-web",
      "host": "web-1",
      "event": "restart",
      "timestamp": "2024-01-15T10:25:00Z",
      "details": {
        "exit_code": 0,
        "reason": "manual"
      }
    }
  ]
}

Get Container Logs

GET /api/v1/containers/:id/logs
Query Parameters:
  • tail - Number of lines from end (default: 100)
  • since - Logs since timestamp
  • stdout - Include stdout (default: true)
  • stderr - Include stderr (default: true)
Response:
{
  "container": "nginx-web",
  "logs": [
    {
      "timestamp": "2024-01-15T10:30:00Z",
      "stream": "stdout",
      "message": "10.0.0.1 - - [15/Jan/2024:10:30:00 +0000] \"GET / HTTP/1.1\" 200 612"
    }
  ]
}