Skip to content

Server doesn't validate Docker image existence before creating containers #9

@alanops

Description

@alanops

Problem

The server attempts to create containers from Docker images without checking if those images exist, leading to confusing errors.

Current Behavior

  • Server maps scenario IDs to image names
  • Directly attempts docker run without validation
  • If image doesn't exist: "Unable to find image 'devopslearn/scenario-keycloak-crashloop:latest' locally"

Expected Behavior

  • Server should check if required images are built
  • Provide clear error messages if images are missing
  • Guide users to run make scenario-build

Root Cause

In src/server/index.ts, the startScenarioContainer function:

const imageMap: Record<string, string> = {
  'k8s-crashloop': 'devopslearn/scenario-keycloak-crashloop',
  // ...
};
// No validation before:
const child = spawn('docker', args);

Solution

  1. Add image existence check before container creation
  2. Return meaningful error to client if image missing
  3. Include instructions for building images

Impact

  • Poor user experience when images aren't built
  • Cryptic Docker errors instead of actionable messages
  • Users don't know they need to run make scenario-build

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions