This paper presents a novel real-time quasi-optimal trajectory generator, based on the inverse dynamics in the virtual domain (IDVD) method, to produce a reliable and efficient guidance system for autonomous underwater vehicle (AUV) docking operations. To this end, a challenging docking scenario is defined in a cluttered operating field, encompassing ocean currents and no-fly zones. Using the IDVD method, a trajectory that takes into consideration the hydrodynamic model of the vehicle is generated and the optimality of this trajectory, in regards to mission time and energy expenditure of the vehicle, is considered. Computer simulations demonstrate that the IDVD-based strategy enables the guiding of a vehicle into the dock by satisfying the final boundary conditions of the dock's position and orientation. Generated trajectories are feasible, smooth and realizable using for the vehicle's low-level auto-pilot module. In terms of computation, the solution is suitable for real-time implementation that incorporates uncertainty handling of the operating environment. For further analysis, the generated trajectory is evaluated on a high fidelity AUV simulator. The result of this latter test also demonstrates applicability of the utilized IDVD method for optimization of docking trajectories.