docker | docker-compose exec bash
Estimatedreadingtime:3minutesExecuteacommandinarunningcontainer.Usage$dockercomposeexec[options][-eKEY=VAL...][--]SERVICECOMMAND[ARGS...]Refertotheoptionssection[1]foranoverviewofavailableOPTIONS[2]forthiscommand.DescriptionThisistheequivalentofdockerexectargetingaComposeservice.Withthissubcommandyoucanrunarbitrarycommandsinyourservices.CommandsarebydefaultallocatingaTTY,soyoucanuseacommandsuchasdockercomposeexecwebshtogetaninteractiveprompt.OptionsName,shorthandDefaultDescription--detach,-d...
Estimated reading time: 3 minutes
Execute a command in a running container.
Usage $ docker compose exec [options] [-e KEY=VAL...] [--] SERVICE COMMAND [ARGS...]Refer to the options section[1] for an overview of available OPTIONS[2] for this command.
DescriptionThis is the equivalent of docker exec targeting a Compose service.
With this subcommand you can run arbitrary commands in your services. Commands are by default allocating a TTY, so you can use a command such as docker compose exec web sh to get an interactive prompt.
Options Name, shorthand Default Description --detach , -d Detached mode: Run command in the background. --env , -e Set environment variables --index 1 index of the container if there are multiple instances of a service [default: 1]. --interactive , -i true Keep STDIN open even if not attached. --no-TTY , -T ...