user3231191
user3231191

Reputation: 141

How to docker-compose run in windows?

How to use this command in windows 10 familly :

docker-compose run api composer install --no-interaction

Example:

docker-compose run api composer install --no-interaction
- Interactive mode is not yet supported on Windows.
Please pass the -d flag when using `docker-compose run`.

Is it possible ?
Do you have an example ?

Upvotes: 4

Views: 5055

Answers (2)

Mouhamed
Mouhamed

Reputation: 1

Simpler alternative is to use option -d and to get logs

docker-compose run -rm <service> <command>

is replaced by:

docker-compose-run <service> <command>

For this to work, add this snippet in your ~/.bashrc :

docker-compose-run() {
    CONTAINER_NAME=$(docker-compose run -d $@)
    docker logs -f $CONTAINER_NAME
    docker rm $CONTAINER_NAME
}

Upvotes: 0

VonC
VonC

Reputation: 1323633

The interactive mode support for docker-compose on Windows is tracked by issue 2836 which proposes some alternatives:

Script ( put the function in ~/.zshrc or ~/.bashrc in a Windows git bash shell for instance):

#!/bin/bash

function docker-compose-run() {
        if [ "$1" = "-f" ] || [ "$1" = "--file" ] ; then
                docker exec -i $(docker-compose -f $2 ps $3 |grep -m 1 $3 | cut -d ' ' -f1) "${@:4}"
        else
                docker exec -i $(docker-compose ps $1 | grep -m 1 $1 | cut -d ' ' -f1) "${@:2}"
        fi
}

docker-compose-run "$@"

Usage:

usage:

docker-compose-run web rspec

# or:

docker-compose-run -f docker-compose.development.yml web rspec

Upvotes: 3

Related Questions