How to start up the tasks of a nomad job in a specific order

Hi,

i am new to Nomad and have an application which consists of 3 middleware docker container and 3 docker containers which are my application. I need to have the middleware started before my application starts. I have added the lifecycle block for the middleware tasks like this:

lifecycle {
hook = "prestart"
sidecar = true
}

But my application cannot connect to the middleware when starting.

Any ideas?

Thanks for your help in advance.

Mihael

My solution was to use another docker container to wait until that health check for the middleware was good.

task "wait-for-solr" {
	lifecycle {
		hook    = "prestart"
		sidecar = false
	}

	driver = "docker"

	config {
		image   = "badouralix/curl-jq:alpine"
		command = "/bin/sh"
		args = [
			"-c",
			"until curl -fsS http://${NOMAD_ADDR_solr}/api/node/health | jq -e '.status == \"OK\"'; do echo \"Waiting for Solr ...\"; sleep 2; done"
		]
	}
}