Skip to main content

Overview

Dockhand provides browser-based terminal access to running containers using xterm.js and WebSocket connections. Execute commands, run interactive shells, and manage containers without SSH or local Docker CLI access.

Terminal Access

Creating an Exec Session

Start a shell session in a container:
Request body:
Response:

Implementation

WebSocket Connection

Connecting to Terminal

Once an exec session is created, connect via WebSocket:

Docker Stream Format

Docker multiplexes stdout/stderr using 8-byte headers:
Parser implementation:

Terminal Emulator

xterm.js Integration

The frontend uses xterm.js for terminal emulation:

Shell Selection

Detecting Available Shells

Automatically detect which shell is available in the container:

Shell-Specific Features

User Selection

Running as Different Users

Execute shell as any user in the container:

Permission Implications

Advanced Features

Command History

Shells with history support maintain command history:

Tab Completion

Bash and Zsh support tab completion:

Copy/Paste Support

Terminal Resize

Dynamically resize terminal to match window:

Multiple Terminals

Tabbed Interface

Open multiple terminals to the same or different containers:

Security Considerations

Authentication

All terminal sessions require authentication:

Authorization

Users need containers:exec permission:

Audit Logging

All exec sessions are logged:

Session Timeout

Terminal sessions timeout after inactivity:

Best Practices

Terminal Usage

  1. Close sessions when done to free resources
  2. Use appropriate user - avoid root when possible
  3. Don’t run long tasks - use scheduled jobs instead
  4. Monitor resource usage - terminals consume memory
  5. Audit sensitive operations - track who did what

Shell Selection

  1. Try bash first - most feature-rich
  2. Fall back to sh - guaranteed to exist
  3. Test shell availability before creating exec
  4. Match container’s default - respect Dockerfile USER

Performance

  1. Limit scrollback - reduce memory usage
  2. Close inactive terminals - free connections
  3. Use connection pooling - reuse WebSocket connections
  4. Throttle output - prevent browser overload

Troubleshooting

Connection Failed

Solutions:
  1. Check container is running
  2. Verify Docker daemon is accessible
  3. Check firewall rules
  4. Ensure WebSocket proxy is configured correctly

Shell Not Found

Solution: Try different shell (/bin/sh, /bin/ash)

Permission Denied

Solutions:
  1. Check container security settings
  2. Try running as root user
  3. Verify container is not in restricted mode

Terminal Not Rendering

Solutions:
  1. Resize terminal window
  2. Send newline character to trigger refresh
  3. Check xterm.js theme configuration
  4. Clear terminal and reconnect

Limitations

Container Requirements

  • Container must be running
  • Shell must be present in container
  • Container must allow exec (no --no-new-privileges flag)

Browser Limitations

  • Requires WebSocket support
  • May have issues with mobile browsers
  • Limited clipboard integration
  • No true terminal emulation (only ANSI escape codes)

Docker API Limitations

  • No TTY resizing after creation (must recreate exec)
  • Limited signal support
  • No job control (background processes)

API Reference