| title | container-compose exec |
|---|---|
| description | Execute a command in a running service container. |
Execute a command in a running service container.
container-compose exec [global-options] [options] service command [args...]| Flag | Shorthand | Type | Default | Description |
|---|---|---|---|---|
--detach |
-d |
flag | Run command in the background | |
--no-interactive |
flag | Disable STDIN passthrough (default: interactive is on) | ||
--no-tty |
flag | Disable TTY allocation (default: tty is on) | ||
--environment |
-e |
string | Set an environment variable KEY=VALUE (can be repeated) | |
--user |
-u |
string | Run as specified username or uid | |
--workdir |
-w |
string | Working directory inside the container | |
--file |
-f |
path | The path to your Docker Compose file |
| Argument | Description |
|---|---|
service |
The service to execute a command in |
command |
Command to execute |
Execute sh in the already running web container.
container-compose exec web shRun a database command as the root user.
container-compose exec -u root db psqlExecute a command in the /app/src directory.
container-compose exec -w /app/src web ls -l