Short answer: the thin vertical line in your Dock is a resize handle, and you are catching it with the pointer without meaning to.
macOS gives you no way to undo that, and no way to type in the size you had. Below is why it happens, and the three ways to make it stop.
Look at your Dock and find the thin line separating your apps from the Downloads folder and Trash. That line is a drag handle. Click and drag it up or down and every icon in the Dock rescales.
It sits at the bottom of the screen, in the same strip of pixels you cross whenever you reach for the Dock, aim at a window edge, or grab a scrollbar. There is no click-and-hold delay, no confirmation. A single stray drag is enough.
What makes it hard to shrug off is that macOS does not store the size you had before and offers no undo. Your only way back is to drag the divider by hand until it looks right again.
The Dock size slider in System Settings has the same problem. It is a slider with no number on it. There is no readout telling you that you were on 48 and are now on 61, so you cannot return to a value you never knew.
A taller Dock takes vertical space away from everything above it. macOS shrinks the usable desktop area, and windows that were sized to fit get pushed and resized to match.
So one accidental brush of the divider changes your icons and rearranges a window layout you spent time building. On a carefully arranged desktop, dragging things back takes ten minutes, and there is no undo.
If your Dock changes when you have not touched the divider, one of these is usually why:
If you landed here wanting to resize the Dock on purpose, there are two ways, and the second is the reason this page exists.
System Settings. Desktop & Dock, then the Size slider at the top. Nudge it, look at the result, and come back to it later.
The divider. Drag the thin line between your apps and the Trash. Faster, and the reason the Dock keeps changing size by accident, because the same handle works whether you meant it or not.
Neither one shows you a number. There is no numeric Dock size field anywhere in System Settings, which is why getting back to a size you liked is guesswork.
System Settings, then Desktop & Dock, then Position on screen. A side Dock keeps the divider out of the path your pointer takes along the bottom of the screen, so you catch it far less often.
Moving the Dock to the side leaves the Dock resizable. The divider just ends up somewhere you reach less often.
macOS has a hidden setting that makes the Dock refuse to resize. It does not appear in System Settings, and it works. Open Terminal and run:
defaults write com.apple.dock size-immutable -bool true; killall Dock
Your Dock will vanish and reappear, which is the killall Dock part doing its job. The setting does nothing until the Dock restarts. From then on the divider will not budge.
To undo it, run the same line with false:
defaults write com.apple.dock size-immutable -bool false; killall Dock
Two things to know. While the lock is on, the Dock size slider in System Settings stops working, and macOS says the setting has been configured by a profile, with no sign that it was you. And the lock holds whatever size you were on when you ran it, so get the size right first.
There are three more of these settings, covering position, contents and auto-hide. We list all four in the Dock settings Apple never gave you a switch for.
The Terminal route works and costs nothing. What it does not do is remember the Dock you had before you locked it, or let you change your mind without going back to Terminal.
Still Dock, an app that locks the Mac Dock, was built to lock the Dock size. It is the same underlying settings behind four switches in your menu bar. Flip the size lock and the divider stops responding. Flip it back and your Dock returns to exactly the size it was before you locked it, because the app recorded it. Delete the app and everything reverts.
You can try the behavior in your browser on the home page, no download required.
Using more than one screen? Jumping between screens is a separate problem with its own fixes: how to keep the Mac Dock on one screen. If the Dock only changes size when a display is plugged in or unplugged, the cause is different again: see why the Dock resizes when you connect a monitor.
Locking the size is one option of several: how to lock the Dock on a Mac, three ways compared.
No. Size and contents are separate settings. With only the size locked you can still add, remove and rearrange apps, though remember that adding an app to a full Dock is itself a reason icons rescale.
System Settings, Desktop & Dock, and move the Size slider. Dragging the divider beside the Trash does the same thing faster. Neither shows a number, so if you want a specific size you can return to, you need to record the number somewhere else.
Yes. It is a stored preference, so it holds across restarts and logins until you turn it off.
Yes. These settings have worked for many years and still work on current macOS. We test on macOS 26.
There is no correct answer, but decide before you lock it. Set the Dock how you like it in System Settings first, then apply the lock, because the lock freezes whatever is current.
The exact key behind the size lock, and every other Dock setting, is in every Mac Dock defaults command.