docker-compose exec <service> <command...>

Execute a command in a running container

Arguments

NameDescription
service
command

Options

NameDescription
--detach, -dDetached mode: Run command in the background
--env, -e <key=value>
  • Repeatable ♾
--index <index>Index of the container if there are multiple instances of a service [default: 1]
--interactive, -iKeep STDIN open even if not attached
--no-TTY, -TDisable pseudo-TTY allocation. By default `docker compose exec` allocates a TTY
--privilegedGive extended privileges to the process
--tty, -tAllocate a pseudo-TTY
--user, -u <user>Run the command as this user
--workdir, -w <workdir>Path to workdir directory for this command