1

I'm trying to learn to write my own Makefiles for docker automation. I've read a bit about this subject and than tried to copy some example code I found online but it gives me an error. Any ideas?

$ make build
make: *** No rule to make target '-f', needed by 'build'.  Stop.

NS ?= test
VERSION ?= latest
IMAGE_NAME ?= test
CONTAINER_NAME ?= test
build:
    docker build -t $(NS)/$(IMAGE_NAME):$(VERSION) -f Dockerfile .

run:
    docker run -d --rm --name $(CONTAINER_NAME) $(NS)/$(IMAGE_NAME):$(latest)

default: build
sebastian_t
  • 2,241
  • 6
  • 23
  • 39
  • 1
    You don't seem to be showing the part of your Makefile which defines a target `-f` – tripleee Jan 31 '18 at 05:55
  • But its an option of ```docker build``` command. So you are saying I've defined my command to run on build incorrectly? What the correct form should be when the command to run is ```docker build -t test/test:latest -f Dockerfile .``` ? – sebastian_t Jan 31 '18 at 06:55
  • 2
    First things first. Does your Makefile have a tab before each `docker` command? – tripleee Jan 31 '18 at 06:57
  • Ok that explains it. Stupid mistake. My editor automatically replaces all tabs with 4 spaces. Now it works correctly. Thank you – sebastian_t Jan 31 '18 at 07:02

1 Answers1

3

Thanks to @tripleee for pointing out that spaces preceding my docker command should actually be a tab.

My editor was changing them to spaces automatically.

sebastian_t
  • 2,241
  • 6
  • 23
  • 39