docker-compose - No such service via Vagrant-Windo

2019-07-25 13:58发布

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:

  • 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!

Any suggestions?

1条回答
祖国的老花朵
2楼-- · 2019-07-25 14:24

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
查看更多
登录 后发表回答