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.

If you want to lock the dock so that you can't resize it, run this command in a terminal:

defaults write com.apple.dock size-immutable -bool yes && killall Dock

If you want to unlock the dock so that you can resize it, run this command in a terminal:

defaults write com.apple.dock size-immutable -bool no && killall Dock

Source


I would recommend setting your dock to minimise program window to their app icon. To do this go into your docks settings and click the option that states "minimise to dock icon"

This should prevent the dock from growing better or smaller. However the more programs you run the dock will increase in size. I suggest pinning the programs to the dock that you use most often and then resize your windows.