Floating or fixed docks matter not for the motion you're describing. Long leads on bow and stern lines, which may be hard to achieve, may be supplemented by long leads on the fore and aft spring lines. You can then take a strain on them and rely on the elasticity of a long line to keep you positioned and alongside.
If you're on a floating dock you can snug up the breast lines as well. Long leads, possibly across to the offshore side of the boat, help there as well. I prefer them tight with suitable large fenders and tolerating the rubbing of gelcoat. Slack offers the opportunity for a fender to ride out of position as well as more potential for the hull to be holed upon something protruding from the dock. Others differ with me on this matter. I'm not cosmetically fixated. I am, however, structurally fixated and that's why I take this position. As always, different ships, different long splices.
“Scientists are people who build the Brooklyn Bridge and then buy it.”
Wm. F. Buckley, Jr.