The Dock is one of the most essential UI elements on macOS. It serves as a quick-launch location for apps that you use often, and for accessing apps and folders that are currently open. The Dock is fully customizable; you can add/remove items from it, change its size, its position on the screen, hide/unhide it, enable/disable animations, and you can choose which apps are pinned to the Dock. If you’d like to prevent any changes from being made to it, you can lock the Dock to do so. The lock option isn’t built into the UI. Instead, you have to use a terminal command.
Lock the Dock
Before you lock the Dock, you should set it up exactly the way you want it to look. It’s a good idea to use it with its current layout for a few days so that you know it works for you. If you’re satisfied with the layout, open Terminal and run the following commands, one by one.
defaults write com.apple.dock contents-immutable -bool true killall Dock
When you right-click any of the apps pinned to the Dock, the option to remove it from the Dock will be absent.
Unlock the Dock
To unlock the Dock, open Terminal and run the following commands one by one.
defaults write com.apple.dock contents-immutable -bool false killall Dock
When you right-click apps pinned to the Dock, the option to remove them will be back. You will also be able to add apps and folders to the Dock.
Locking the Dock does not require admin user authentication. This means that if you lock the Dock for a particular user, that user can probably figure out what’s going on and unlock the Dock. This terminal command, while really useful, is hardly a good way to enforce some sort of layout on a system.
A locked Dock won’t allow a user to add items to it but, new apps that open, new files, and new folders will still appear on it. You will not be able to rearrange items on the Dock. Locking the Dock prevents changes to it but it remains as functional as ever. New item badges continue to appear on it, and any app action progress e.g., file download progress will still show on the icon for an app.
While this command is strictly for locking and unlocking the Dock, it might help to fix problems you’re having with the Dock. If you’re unable to add items to the Dock, or items tend to keep disappearing, running the unlock command might help.