Makefile- Return value from another target

  docker, global-variables, makefile, return-value

I created two targets in one Makefile.
The generic target docker-get-label should read the label value from specific docker container and returns it.
But the var $(LABEL_VALUE) in target testtarget is empty and prints out nothing.
Inside target docker-get-label I can print out the var LABEL_VALUEsuccessfully.

Does exist a way to get a value from another target, from the target docker-get-label?

testtarget:
    $(MAKE) docker-get-label CONTAINER_NAME=xenodochial_maxwell
    echo $(LABEL_VALUE) #empty


docker-get-label:
    $(eval LABEL_VALUE=$(shell docker inspect -f '{{ index .Config.Labels "TESTLABELNAME"}}' $(CONTAINER_NAME)))

Source: Docker Questions

LEAVE A COMMENT