Skip to main content

Opening a Shell

oc shell sb-abc123
Opens a full interactive terminal over WebSocket. Press Ctrl+D or type exit to disconnect.

Choosing a Shell

oc shell sb-abc123 --shell /bin/zsh
Default: /bin/bash.

What Works

The PTY supports everything you’d expect from a real terminal:
  • Editors: vim, nano
  • Monitors: top, htop
  • Tab completion and command history
  • Colors and ANSI escape codes
  • Terminal resizing — automatic, resize events forwarded
Full-screen applications like tmux and less work correctly.

Shell vs Exec

Use CaseCommand
Run a single command, capture outputoc exec --wait
Scripting and automationoc exec --wait --json
Interactive developmentoc shell
Debuggingoc shell

Tips

Create and Shell In

oc shell $(oc create --json | jq -r '.sandboxID')

Shell with Custom Environment

Set up the environment before shelling in:
ID=$(oc create --json | jq -r '.sandboxID')
oc exec $ID --wait -- bash -c 'echo "export PATH=/app/bin:\$PATH" >> ~/.bashrc'
oc shell $ID
SDK usage: Interactive Terminals. Full flags: CLI Reference.