Mode-locking is predicted in a nanolaser cavity forming an effective photonic harmonic potential. The cavity is substantially more compact than a Fabry-Perot resonator with comparable pulsing period, which is here controlled by the potential. In the limit of instantaneous gain and absorption saturation, mode-locking corresponds to a stable dissipative soliton, which it very well approximated by the coherent state of a quantum mechanical harmonic oscillator. This property is robust against non-instantaneous material response and non-zero phase-intensity coupling.