Running a task as different user

I am running nomad server and client as root and I have a simple batch task which I would like to run as user “foo”.

So I did
user = “foo”

But I get the error
"failed to launch command with executor: rpc error: code = Unknown desc = container_linux.go:349:starting container process caused “setup user: unable to find user foo: no matching entries in passwd file”.

The user foo is not in the passwd file because we get it from NIS. Is there another way around it?

If I do,

getent foo

The user resolves.