Next does not work:
nomad alloc exec -task postgres-task 48a14dcd-63e2-e2d0-d31e-2a3ecd4b9240 psql -h 127.0.0.1 -U postgres
Usage: nomad alloc exec [options] <allocation> <command>
Run command inside the environment of the given allocation and task.
When ACLs are enabled, this command requires a token with the 'alloc-exec',
'read-job', and 'list-jobs' capabilities for the allocation's namespace. If
the task driver does not have file system isolation (as with 'raw_exec'),
this command requires the 'alloc-node-exec', 'read-job', and 'list-jobs'
capabilities for the allocation's namespace.
...
Though this works:
nomad alloc exec -task postgres-task 48a14dcd-63e2-e2d0-d31e-2a3ecd4b9240 psql -U postgres
psql (11.11 (Debian 11.11-1.pgdg90+1), server 11.12 (Debian 11.12-1.pgdg90+1))
Type "help" for help.
postgres=#