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: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: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 needcontainers:exec permission:
Audit Logging
All exec sessions are logged:Session Timeout
Terminal sessions timeout after inactivity:Best Practices
Terminal Usage
- Close sessions when done to free resources
- Use appropriate user - avoid root when possible
- Don’t run long tasks - use scheduled jobs instead
- Monitor resource usage - terminals consume memory
- Audit sensitive operations - track who did what
Shell Selection
- Try bash first - most feature-rich
- Fall back to sh - guaranteed to exist
- Test shell availability before creating exec
- Match container’s default - respect Dockerfile USER
Performance
- Limit scrollback - reduce memory usage
- Close inactive terminals - free connections
- Use connection pooling - reuse WebSocket connections
- Throttle output - prevent browser overload
Troubleshooting
Connection Failed
- Check container is running
- Verify Docker daemon is accessible
- Check firewall rules
- Ensure WebSocket proxy is configured correctly
Shell Not Found
/bin/sh, /bin/ash)
Permission Denied
- Check container security settings
- Try running as root user
- Verify container is not in restricted mode
Terminal Not Rendering
- Resize terminal window
- Send newline character to trigger refresh
- Check xterm.js theme configuration
- Clear terminal and reconnect
Limitations
Container Requirements
- Container must be running
- Shell must be present in container
- Container must allow exec (no
--no-new-privilegesflag)
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)
