docker compose run
Description
Run a one-off command on a service.
Usage
$ docker compose run [options] [-v VOLUME...] [-p PORT...] [-e KEY=VAL...] [-l KEY=VALUE...] SERVICE [COMMAND] [ARGS...]
Options
Name, shorthand | Default | Description |
--detach , -d |
Run container in background and print container ID | |
--entrypoint |
Override the entrypoint of the image | |
--env , -e |
Set environment variables | |
--labels , -l |
Add or override a label | |
--name |
Assign a name to the container | |
--no-TTY , -T |
Disable pseudo-tty allocation. By default docker compose run allocates a TTY | |
--no-deps |
Don't start linked services. | |
--publish , -p |
Publish a container's port(s) to the host. | |
--rm |
Automatically remove the container when it exits | |
--service-ports |
Run command with the service's ports enabled and mapped to the host. | |
--use-aliases |
Use the service's network useAliases in the network(s) the container connects to. | |
--user , -u |
Run as specified username or uid | |
--volumes , -v |
Bind mount a volume. | |
--workdir , -w |
Working directory inside the container |
Parent command
Command | Description |
---|---|
docker compose | Docker Compose |
Related commands
Command | Description |
docker compose build | Build or rebuild services |
docker compose convert | Converts the compose file to platform’s canonical format |
docker compose create | Creates containers for a service. |
docker compose down | Stop and remove containers, networks |
docker compose events | Receive real time events from containers. |
docker compose exec | Execute a command in a running container. |
docker compose kill | Force stop service containers. |
docker compose logs | View output from containers |
docker compose ls | List running compose projects |
docker compose pause | pause services |
docker compose ps | List containers |
docker compose pull | Pull service images |
docker compose push | Push service images |
docker compose rm | Removes stopped service containers |
docker compose run | Run a one-off command on a service. |
docker compose start | Start services |
docker compose stop | Stop services |
docker compose top | Display the running processes |
docker compose unpause | unpause services |
docker compose up | Create and start containers |