Skip to content

feat: Add container exec functionality with comprehensive API#86

Closed
Talador12 wants to merge 1 commit intocloudflare:mainfrom
Talador12:feature/container-exec
Closed

feat: Add container exec functionality with comprehensive API#86
Talador12 wants to merge 1 commit intocloudflare:mainfrom
Talador12:feature/container-exec

Conversation

@Talador12
Copy link
Copy Markdown

  • Adds exec() method to Container class for executing commands in running containers
  • Automatic container startup and health checking - no manual state management required
  • Support for string commands, command arrays, and rich execution options
  • Configurable working directory, environment variables, and timeout
  • Comprehensive error handling with proper exit codes and timeout support
  • Returns detailed ExecResult with stdout, stderr, exit code, success flag, and duration
  • Uses HTTP communication to container's /__exec endpoint for command execution
  • Comprehensive test coverage for all execution scenarios and error cases

- Adds exec() method to Container class for executing commands in running containers
- Automatic container startup and health checking - no manual state management required
- Support for string commands, command arrays, and rich execution options
- Configurable working directory, environment variables, and timeout
- Comprehensive error handling with proper exit codes and timeout support
- Returns detailed ExecResult with stdout, stderr, exit code, success flag, and duration
- Uses HTTP communication to container's /__exec endpoint for command execution
- Comprehensive test coverage for all execution scenarios and error cases
Comment thread src/lib/container.ts
AbortSignal.any ? AbortSignal.any(signals) : controller.signal;

// Make HTTP request to container's exec endpoint
const response = await tcpPort.fetch('http://container/__exec', {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this __exec endpoint come from?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to rewrite this section to use the SSH integration

@Talador12
Copy link
Copy Markdown
Author

Blocked on cloudflare/workers-sdk#10582

Will update this PR when that one is merged

@Talador12
Copy link
Copy Markdown
Author

Tied to
cloudflare/containers-demos#17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants