YouTip LogoYouTip

Docker Compose Run Command

# docker compose run command [![Image 3: Docker Command Manual](#)Docker Command Manual](#) * * * The docker compose run command is used to start a new container and run a specific service without starting all services defined in the Compose file. The docker compose run command allows you to execute tasks on a single service, such as running one-time commands or debugging. Unlike docker compose up, the run command only runs the specified service and does not start other services that depend on it. ### Syntax docker compose run SERVICE [ARGS...] * **SERVICE**: The service name defined in the Compose file. * **COMMAND** and **ARGS**: Optional parameters that specify the command to run inside the container and its arguments. **OPTIONS:** * `--rm`: Automatically delete the container after running. * `-d`: Run the container in detached mode. * `-T`: Disable pseudo-TTY. ### Examples **1、Run a command for a specific service** docker compose run web python manage.py migrate This command will execute the python manage.py migrate command in the web service's container without starting other services. **2、Automatically delete the container** docker compose run --rm web bash This command will run the web service and start a Bash terminal, and the container will be deleted after the task completes. docker compose run is very suitable for executing one-time tasks in a service without affecting the operation of other services. * * Docker Command Manual](#)
← Regex Tutorial - Getting StartPython File Handling β†’