mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
feat: "exec" command to start processes inside remote containers (#139)
This commit is contained in:
@@ -18,6 +18,7 @@ A CLI tool for managing Uncloud resources such as machines, services, and volume
|
||||
* [uc ctx](uc_ctx.md) - Switch between different cluster contexts. Contains subcommands to manage contexts.
|
||||
* [uc deploy](uc_deploy.md) - Deploy services from a Compose file.
|
||||
* [uc dns](uc_dns.md) - Manage cluster domain in Uncloud DNS.
|
||||
* [uc exec](uc_exec.md) - Execute a command in a running service container
|
||||
* [uc image](uc_image.md) - Manage images on machines in the cluster.
|
||||
* [uc images](uc_images.md) - List images on machines in the cluster.
|
||||
* [uc inspect](uc_inspect.md) - Display detailed information on a service.
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# uc exec
|
||||
|
||||
Execute a command in a running service container
|
||||
|
||||
## Synopsis
|
||||
|
||||
Execute a command (interactive shell by default) in a running container within a service.
|
||||
If the service has multiple replicas, the command will be executed in a random container.
|
||||
|
||||
|
||||
```
|
||||
uc exec [OPTIONS] SERVICE [COMMAND ARGS...] [flags]
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
|
||||
# Start an interactive shell ("bash" or "sh" will be tried by default)
|
||||
uc exec web-service
|
||||
|
||||
# Start an interactive shell with explicit command
|
||||
uc exec web-service /bin/zsh
|
||||
|
||||
# List files in the specific container of the service
|
||||
uc exec --container d792ea7347e5 web-service ls -la
|
||||
|
||||
# Pipe input to a command inside the service container
|
||||
cat /var/log/app.log | uc exec -T web-service grep "ERROR"
|
||||
|
||||
# Run a task in the background (detached mode)
|
||||
uc exec -d web-service /scripts/cleanup.sh
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
```
|
||||
--container string ID of the container to exec into (default is the random container of the service)
|
||||
-c, --context string Name of the cluster context. (default is the current context)
|
||||
-d, --detach Detached mode: run command in the background
|
||||
-h, --help help for exec
|
||||
-T, --no-tty Disable pseudo-TTY allocation. By default 'uc exec' allocates a TTY when connected to a terminal.
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
||||
```
|
||||
--connect string Connect to a remote cluster machine without using the Uncloud configuration file. [$UNCLOUD_CONNECT]
|
||||
Format: [ssh://]user@host[:port] or tcp://host:port
|
||||
--uncloud-config string Path to the Uncloud configuration file. [$UNCLOUD_CONFIG] (default "~/.config/uncloud/config.yaml")
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
* [uc](uc.md) - A CLI tool for managing Uncloud resources such as machines, services, and volumes.
|
||||
|
||||
@@ -19,6 +19,7 @@ Manage services in an Uncloud cluster.
|
||||
## See also
|
||||
|
||||
* [uc](uc.md) - A CLI tool for managing Uncloud resources such as machines, services, and volumes.
|
||||
* [uc service exec](uc_service_exec.md) - Execute a command in a running service container
|
||||
* [uc service inspect](uc_service_inspect.md) - Display detailed information on a service.
|
||||
* [uc service ls](uc_service_ls.md) - List services.
|
||||
* [uc service rm](uc_service_rm.md) - Remove one or more services.
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# uc service exec
|
||||
|
||||
Execute a command in a running service container
|
||||
|
||||
## Synopsis
|
||||
|
||||
Execute a command (interactive shell by default) in a running container within a service.
|
||||
If the service has multiple replicas, the command will be executed in a random container.
|
||||
|
||||
|
||||
```
|
||||
uc service exec [OPTIONS] SERVICE [COMMAND ARGS...] [flags]
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
|
||||
# Start an interactive shell ("bash" or "sh" will be tried by default)
|
||||
uc exec web-service
|
||||
|
||||
# Start an interactive shell with explicit command
|
||||
uc exec web-service /bin/zsh
|
||||
|
||||
# List files in the specific container of the service
|
||||
uc exec --container d792ea7347e5 web-service ls -la
|
||||
|
||||
# Pipe input to a command inside the service container
|
||||
cat /var/log/app.log | uc exec -T web-service grep "ERROR"
|
||||
|
||||
# Run a task in the background (detached mode)
|
||||
uc exec -d web-service /scripts/cleanup.sh
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
```
|
||||
--container string ID of the container to exec into (default is the random container of the service)
|
||||
-c, --context string Name of the cluster context. (default is the current context)
|
||||
-d, --detach Detached mode: run command in the background
|
||||
-h, --help help for exec
|
||||
-T, --no-tty Disable pseudo-TTY allocation. By default 'uc exec' allocates a TTY when connected to a terminal.
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
||||
```
|
||||
--connect string Connect to a remote cluster machine without using the Uncloud configuration file. [$UNCLOUD_CONNECT]
|
||||
Format: [ssh://]user@host[:port] or tcp://host:port
|
||||
--uncloud-config string Path to the Uncloud configuration file. [$UNCLOUD_CONFIG] (default "~/.config/uncloud/config.yaml")
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
* [uc service](uc_service.md) - Manage services in an Uncloud cluster.
|
||||
|
||||
Reference in New Issue
Block a user