Possibly no interface element characterizes macOS with as much personality as Dock. Even though many prefer to hide it, potato: Even a tech-savvy person, seeing that bottom-centered application bar, knows he's dealing with an Apple computer.
Dock has been around for so long precisely because it works and a simple way to bring together your machine's most used applications for instant access. Not everyone uses the computer in the same way, however, someone might prefer a different approach to the element, such as a behavior where it only shows apps currently open. And before you ask, yes, that's possible.
To make Dock display only open apps, simply open Terminal (which is in the "Utilities" folder of your Applications directory) and paste it with the following command:
defaults write com.apple.dock static-only -bool true; killall Dock
Once pasted, simply press Enter; Dock restarts and only shows open apps. Remember that the system does not save the ordering of the icons before the change; If you want to go back to the previous behavior, then having to rearrange the applications as they once were might be a good idea to take a screenshot to remember.
Speaking of returning to the previous behavior, to restore the Dock to its original operation just paste the opposite command in Terminal, followed by Enter. This one:
defaults write com.apple.dock static-only -bool false; killall Dock
Note that we only change true to false, nothing more.
Ready! Recalling that by default the Mac gives no indication of which applications are open or not in the Dock; To change this setting, simply access your preferences by clicking anywhere in the Dock “inactive” (or by going to Dock System Preferences) and selecting the "Show bookmarks for open applications" option.
via Rocket Yard