Target Display Mode is a useful feature available on select iMac models designed so that the user may use their iMac as an external display for their connected MacBook.
Apple has an informative support article, which can be found here, detailing how to utilize this feature. Before continuing further, however, it is important to check that your specific iMac model is supported.
See this table below to find your iMac and, if compatible, which type of cable is needed to utilize the feature:
Apple indicates that the Retina 5K, 27-inch, and Late 2014 iMac models do not support Target display mode and cannot be used as an external display for any MacBook computer.
Another key point to consider is that while Target Display mode is in use, Apple specifically states that the iMac’s ports are not available for use; instead “[to] use external devices with your Mac, connect these devices directly to the Mac you want to use them with.”
The best part about Target Display mode is using your Vertical Dock to keep your cables organized, including your iMac’s display cable. The cable can be routed through the Vertical Dock and installed just like any other compatible cable; the installation mirrors the process used for Apple's Thunderbolt cable.
Please note that if you have the Vertical Dock for MacBook Pro with Retina Display, you will want to remove one of the pre-installed Mini DisplayPort extension cables so that the iMac’s cable can connect directly to the MacBook when it is docked. You can find more information about the setup process here and feel free to download a PDF copy of the dock's User Guide for more detailed installation instructions here.
*For users of the Stone docking station, the iMac must have a mini-DisplayPort connection in order to be used as an external display. Any iMac later than 2010 with Thunderbolt cannot be used as an external display with our Stone Tethered Docking Station.