Dynamics of localization in a waveguide