Skip to content

feat: add exec command for interactive container terminal access#38

Open
vuongquocphong wants to merge 1 commit intoDokploy:mainfrom
vuongquocphong:main
Open

feat: add exec command for interactive container terminal access#38
vuongquocphong wants to merge 1 commit intoDokploy:mainfrom
vuongquocphong:main

Conversation

@vuongquocphong
Copy link
Copy Markdown

Summary

  • Add exec command for interactive terminal access to running containers via WebSocket
  • Support all service types: applications, redis, postgres, mongo, mysql, mariadb, compose
  • Add --project and --env flags for disambiguation across projects/environments
  • No SSH access required — authenticates via existing API key

Closes #37

Usage

# Interactive shell
dokploy exec --app Web

# Run a command
dokploy exec --env staging --app Web rails c

# Disambiguate across projects/environments
dokploy exec --project "My Project" --env staging --app Web rails c

How it works

  1. Resolves service name → container ID via Dokploy API (project.all*.onedocker.getContainersByAppLabel)
  2. Opens WebSocket to /docker-container-terminal (same protocol as web panel Terminal tab)
  3. Pipes raw stdin/stdout for interactive terminal session

Changes

  • src/commands/exec.ts — new hand-authored command
  • src/index.ts — register the exec command
  • package.json — add ws dependency
  • readme.md — documentation for exec command

Test plan

  • Tested dokploy exec --app Web — interactive shell works
  • Tested dokploy exec --app Web rails c — command execution works
  • Tested dokploy exec --app Cache — non-application service types work
  • Tested --env flag for environment filtering
  • Tested ambiguous name detection (prompts user to specify --env/--project)
  • Tested exit — clean disconnect
  • Linted with pnpm run lint

🤖 Generated with Claude Code

Add a new `exec` command that connects to running Dokploy containers
via WebSocket, providing interactive terminal access similar to
`heroku run`. No SSH access required — only a Dokploy API key.

Features:
- Works with all service types (applications, redis, postgres, mongo, mysql, mariadb, compose)
- --project and --env flags for disambiguation across projects/environments
- Automatic container discovery via Dokploy API
- Raw stdin/stdout piping over WebSocket (same protocol as web panel Terminal tab)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

feat: add exec command for interactive container terminal access

1 participant