如何在Windows中使用docker-compose运行?

时间:2016-05-23 08:21:35

标签: windows docker docker-compose boot2docker

如何在Windows 10 familly中使用此命令:

  slack_params = {
    message: 'iOS App successfully released to Hockey!',
    payload: {
      # 'Date' => "#{t.year}-#{t.month}-#{t.day} #{t.hour}:#{t.min} (#{t.zone})",
      # Because we increase the version after each build,
      # but submit before the increase
      'Build' => "#{build_number.to_i - 1}",
      'Version' => version_number,
      'Type' => type
    },
    default_payloads: [:git_branch, :git_author, :last_git_commit]
  }

  if release_lane lane
    slack_params[:message] = 'iOS App successfully submitted to the App Store!'

    commit_tag_and_update_release_branch
  else
    slack_params[:payload]['Download Link'] = "#{Actions.lane_context[Actions::SharedValues::HOCKEY_DOWNLOAD_LINK]}"
  end

  slack slack_params

示例:

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

有可能吗?
你有一个例子吗?

2 个答案:

答案 0 :(得分:3)

issue 2836跟踪了Windows上对docker-compose的交互模式支持,提出了一些替代方案:

脚本(例如,将函数放在{gid bash shell中的~/.zshrc~/.bashrc中):

#!/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 "$@"

用法:

用法:

docker-compose-run web rspec

# or:

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

答案 1 :(得分:0)

更简单的替代方法是使用选项-d并获取日志

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

替换为:

docker-compose-run <service> <command>

要实现此目的,请在~/.bashrc

中添加此代码段
docker-compose-run() {
    CONTAINER_NAME=$(docker-compose run -d $@)
    docker logs -f $CONTAINER_NAME
    docker rm $CONTAINER_NAME
}