1

I'm using:

  • Windows 10
  • make 3.81
  • docker CE 18.09.2
  • docker compose 1.23.2
  • git bash 2.22.0.windows.1

I've got a docker-compose.yaml file that looks like this:

version: '3.2'

services:
  terraform:
    image: hashicorp/terraform:0.11.14
    entrypoint: terraform
    working_dir: /var/tmp/code/
    volumes:
      - .:/var/tmp/code/:rw

And my Makefile looks like this

init:
    docker-compose run terraform init

When I run this from the GitBash command line:

make init

I get the following output

docker-compose run terraform init
process_begin: CreateProcess(NULL, docker-compose run terraform init, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [init] Error 2

I've seen other posts relating to this, and understand this to be a problem with the values on my PATH environment variable, however I'm not sure how to correct the problem.

Please let me know if I can provide any more information


Update

I have confirmed that:

  • docker-compose is installed
  • the docker-compose.exe exists on my PATH environment variable (see below)

My PATH environment variable:

enter image description here


Update 2

If I modify the makefile so it explicitly states the path to the docker-compose.exe file, it works:

init:
    "/c/Program Files/Docker/Docker/resources/bin/docker-compose.exe" run terraform init

Update 3 - Solution

So my full Makefile actually looked like this:

#!make
include .env
export

.env:
    @[ -f ./.env-aws ] && source ./.env-aws; env | grep AWS | sed 's/export //g; s/"//g' > .env

init-test:
    docker-compose run terraform init

Running make .env creates a .env file, which included a PATH env var

AWS_SECRET_ACCESS_KEY=...
AWS_SESSION_TOKEN=...
AWS_ACCESS_KEY_ID=...
PATH=...

Deleting the PATH line from this file solve it for me :)

GreenyMcDuff
  • 3,292
  • 7
  • 34
  • 66
  • 1
    Your screen shot seems to imply that it's installed at `C:\ProgramData\DockerDesktop\version-bin\docker-compose.exe` - can you confirm that this is indeed the case? (Really `ProgramData` not `Program Files`?) What happens if you use the full path in the `Makefile`? (Your `Makefile` would not happen to override `PATH` in a part you are not showing?) – tripleee Jun 21 '19 at 08:07
  • And as always, have you explored getting rid of Windows? – tripleee Jun 21 '19 at 08:08
  • @tripleee, Windows === corporate policy! – GreenyMcDuff Jun 21 '19 at 08:58
  • @tripleee, yes, if i explicitly state the path to `docker-compose.exe` (which is in the location stated in the screenshot), it works. Will update the question – GreenyMcDuff Jun 21 '19 at 09:41
  • 1
    So does your `Makefile` muck with `PATH`? Or does it get lost somehow (what happens if you add `echo "$$PATH"` on a separate tab-indented line after `init:`)? – tripleee Jun 21 '19 at 09:58
  • You were spot on! There is a another command in the `Makefile` that creates' a `.env` file. That had created it's own PATH variable which was overriding the system PATH. Thank you so much! – GreenyMcDuff Jun 21 '19 at 10:11
  • Feel free to post a solution and I'll mark it as an answer so you get the rep ;) – GreenyMcDuff Jun 21 '19 at 10:16

2 Answers2

1

If your Makefile somehow manipulates the PATH variable so that the directory where docker-compose is installed is no longer on it, that would cause this kind of symptom.

For troubleshooting, try to add

echo "$$PATH"

(indented by a tab, of course) just before the failing command, and examine whether the result confirms your expectations.

(The dollar sign needs to be doubled in this context to pass a literal dollar sign from make to the underlying shell.)

tripleee
  • 175,061
  • 34
  • 275
  • 318
0

This means docker-compose not found when execute docker-compose run terraform init in Makefile.

If you not execute make, just docker-compose, you also cannot find docker-compose.

a) If you haven't installed docker-compose, download it from official release site to install it, a direct download link for your reference: https://github.com/docker/compose/releases/download/1.25.0-rc1/docker-compose-Windows-x86_64.exe

b) If you have installed docker-compose, you need to know where you install it. For my site, I installed it in: C:\Program Files\Docker\Docker\Resources\bin, so before execute make init, I add this to PATH:

C:\abc\try>set PATH=C:\Program Files\Docker\Docker\Resources\bin;%PATH%
C:\abc\try>make init

Also, if you want to permanently add the docker-compose path to env, you can reference this to do it.

atline
  • 28,355
  • 16
  • 77
  • 113
  • Thanks for your answer @atline, but I have `docker-compose` installed and the `docker-compose.exe` exists on my PATH env var - I'll update the question with that info – GreenyMcDuff Jun 21 '19 at 07:49