Add cp command to copy files out of containers, binary-safe

`portainer-cli cp <stack> <container>:<path> <dest>` goes through Docker's
archive API, so unlike `console --run "cat …"` there's no TTY in between and
binary files (database dumps) arrive intact. Works like `docker cp` for files
and directories; a dest of "-" writes a single file to stdout.

Stack and container lookup moves from Console into a shared Resolver module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
grzlusandClaude Opus 5.5 committed 2026-10-21 18:57:40 +02:00
1 parent e002cdf170
commit 2d45ce3af8
6 files changed
+282 -100

No files matched your search

+8
View File
@@ -9,6 +9,7 @@ require_relative 'portainer_cli/commands/list'
require_relative 'portainer_cli/commands/create'
require_relative 'portainer_cli/commands/exec'
require_relative 'portainer_cli/commands/console'
require_relative 'portainer_cli/commands/cp'
module PortainerCli
module CLI
@@ -34,6 +35,9 @@ module PortainerCli
--endpoint ID Disambiguate when stack name exists on multiple endpoints
--shell SHELL Shell to use (default: /bin/sh)
--run CMD Run command instead of a bare shell
portainer-cli cp <stack> <container>:<path> <dest> Copy a file/directory out of a container (binary-safe)
--endpoint ID Disambiguate when stack name exists on multiple endpoints
--quiet Suppress status output; <dest> of - writes to stdout
portainer-cli exec <endpoint-id> <container> Open interactive shell (manual endpoint)
--shell SHELL Shell to use (default: /bin/sh)
@@ -60,6 +64,10 @@ module PortainerCli
require_config!(config)
client = Client.new(config)
Commands::Console.new(config, client, debug: debug).run(argv)
when 'cp'
require_config!(config)
client = Client.new(config)
Commands::Cp.new(config, client).run(argv)
when 'exec', 'shell'
require_config!(config)
client = Client.new(config)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.