0

What I want is to run bash command docker-machine ip default put the result in a variable and use that variable in a string and export that variable to environment variable. But that doesn't work out as I expected.

Here's my Makefile so far.

IP := $(docker-machine ip default) 
export DATABASE_URL := "postgres://postgres@$(IP)/postgres"
test:
    echo $(DATABASE_URL)
    py.test tests

When I run make test I get

postgres://postgres@ /postgres
toy
  • 11,711
  • 24
  • 93
  • 176
  • 3
    You missed `shell` in the `IP` assignment line. You meant `IP := $(shell docker-machine ip default)` to run the `docker-machine` shell command. You are telling make to run the `docker-machine` make function. – Etan Reisner Dec 29 '15 at 20:26
  • That's perfect! I did that and it works. Can you put that in answer and I'll accept it. – toy Dec 29 '15 at 20:31
  • 1
    Possible duplicate of [How to assign the output of a command to a Makefile variable](http://stackoverflow.com/questions/2019989/how-to-assign-the-output-of-a-command-to-a-makefile-variable) – David C. Rankin Dec 29 '15 at 20:35

1 Answers1

1

You need to indicate shell command:

IP := $(shell docker-machine ip default)
$(warning IP=$(IP))
levif
  • 2,156
  • 16
  • 14