macOS can lock the Dock. Apple just never gave you a switch for it.
These are the real settings, the same ones any app for this uses underneath. Set your Dock exactly how you want it first, because these freeze whatever is in place when you run them.
Paste this into Terminal and press Return. Applications, then Utilities, then Terminal.
Copied
killall Dock at the end is not optional. The preference changes without it, but the Dock keeps running with the old one, so it looks like nothing happened.magnification-immutable does nothing. It appears on several sites as a fifth lock. It has no effect, and we tested it.If you find yourself running these more than once, that is the whole reason Still Dock, an app that locks your Mac's Dock, exists. Same four settings, as switches in the menu bar, and it remembers the Dock you had before you locked it so you can always get back to it.
The commands above stay free either way. Terminal, profile and app compared.