docker-compose - 没有通过Vagrant-Windows shell这样的服务 [英] docker-compose - No such service via Vagrant-Windows shells only

查看:160
本文介绍了docker-compose - 没有通过Vagrant-Windows shell这样的服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到Vagrant / Docker-Compose的一个问题,似乎是Windows特有的。以下是设置和编排的概述:

I am running into an issue with Vagrant/Docker-Compose that seems to be specific to Windows. Here's an overview of the setup and orchestration:


  • 使用boot2docker框的流氓用户

  • 几个Docker容器在boot2docker VM内运行

  • 运行多个shell脚本的Vagrantfile

  • 在这些shell脚本中,我运行从boot2docker VM调用的命令它是Docker容器的小孩。这些命令的示例如下所示: docker exec -i $(docker-compose ps -q $ DOCKER_DBSVC)/ bin / bash /db/dockersetup/restoreMyDB.sh

  • 在我的Linux Mint框(和Ubuntu框)上运行 vagrant up 产生正确执行所有命令的工作机器

  • 在Windows上运行 vagrant up 在上述命令(和类似命令)上使用没有这样的服务:my-db-服务

  • 在升级容器后,我已经运行 docker-compose config --services ,并可以验证服务名称存在,但无论什么原因,命令在Windows主机上失败!

  • 脚本失败后,机器仍然启动,Docker容器仍然存在。然后我可以通过Windows主机将$ code> vagrant ssh 引入到容器中。

  • Vagrant using a boot2docker box
  • Several docker containers running inside of boot2docker VM
  • Vagrantfile that runs several shell scripts
  • Inside of those shell scripts, I run commands that call out from the boot2docker VM to it's child Docker containers. An example of those commands look like: docker exec -i $(docker-compose ps -q $DOCKER_DBSVC) /bin/bash /db/dockersetup/restoreMyDB.sh
  • Running vagrant up on my Linux Mint box (and an Ubuntu box) yield working machines that execute all commands properly
  • Running vagrant up on Windows fails on the above command (and commands like it) with a No such service: my-db-service
  • I have run docker-compose config --services after upping the containers and can verify that the service names exist, but for whatever reason the command fails on Windows hosts only!
  • After the scripts fail, the machine still boots up and the Docker containers are alive. I can then vagrant ssh into the box (via Windows host), and reference the containers by service name!

任何建议?

推荐答案

行结尾,行尾,行尾。 Windows repos正在检查并将LF转换为CRLF,因此服务名称具有愚蠢的CR位于它们的末尾...要解决此问题,我创建了以下脚本基于此答案

Line endings, line endings, line endings. The Windows repos were checking out and converting LF to CRLF, so the service names had that goofy CR sitting at the end of them... To fix this, I created the following script based on this answer:

#!/bin/bash
git config --global core.autocrlf false
git config --global core.eol lf
git rm --cached -rf .
git diff --cached --name-only -z | xargs -n 50 -0 git add -f

这篇关于docker-compose - 没有通过Vagrant-Windows shell这样的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆