We have identified a physical mechanism that rules the confinement of nonpropagating hydrodynamic solitons. We show that thin boundary layers arising on walls are responsible for a jump in the local damping. The outcome is a weak dissipation-driven repulsion that determines decisively the solitons' long-time behavior. Numerical simulations of our model are consistent with experiments. Our results uncover how confinement can generate a localized distribution of dissipation in out-of-equilibrium systems. Moreover, they show the preponderance of such a subtle effect in the behavior of localized structures. The reported results should explain the dynamic behavior of other confined dissipative systems.