Just for the sake of completeness, here's an example scene with a render node set up to produce a depth pass.
Terje, it's best to output depth passes as high bit files, 16 or 32 bit. An 8-bit file just doesn't have enough levels to store the data. You need floating point. Most software used for post processing (still and video) can handle that. The 32-bit exr file in the attached zip file will look dark in Photoshop, but the data are there. (If you need an 8-bit file you can use an image editor to equalize the 32-bit image first, then save it down to 8-bit. The attached image has been equalized in Photoshop.)
Now, for the sake of argument . . . isn't this the preferred way to create a depth map? It involves no changes to the node network, and the beauty and depth passes can be output simultaneously.