docker compose exec

内容説明Execute a command in a running container
利用方法docker compose exec [OPTIONS] SERVICE COMMAND [ARGS...]

内容説明

This is the equivalent of docker exec targeting a Compose service.

With this subcommand, you can run arbitrary commands in your services. Commands allocate a TTY by default, so you can use a command such as docker compose exec web sh to get an interactive prompt.

オプション

オプションデフォルト内容説明
-d, --detachDetached mode: Run command in the background
-e, --envSet environment variables
--indexIndex of the container if service has multiple replicas
-T, --no-TTYtrueDisable pseudo-TTY allocation. By default docker compose exec allocates a TTY.
--privilegedGive extended privileges to the process
-u, --userRun the command as this user
-w, --workdirPath to workdir directory for this command