How to lock the size of the Dock?
In a word, "No".

The dock is dynamically sized as you have found on the basis of the number of applications stored, or running, and the amount of document windows you may have minimised.

There is no way to stop it exhibiting this behaviour, and if you think about it it would cause considerable usability issues if it were to do so, as the only way to maintain a static width would be dynamic resizing of App/Document icons, which would eventually be too small to usefully identify.

If you don't like the overlap, then you can try a couple of workarounds:


Set the dock to autohide
Open what you consider to be the maximum
number of items in your dock, and scale the size down in preferences
to make it fit in your "gap", then accept that a lot of the time it
will be smaller, even it it shouldn't get much bigger than the gap.
Use a vertical dock to any change of size shouldn'f affect the width.