I share your frustration daily.
I decided to buy the new M1 Pro (16GB RAM) because my old 13' MacBook pro (2017) was unusable due to its sub-hour battery life and unbearable sluggishness. There was always this lag between typing and the text appearing in my editor, which was stressing me out a lot.
At first, I was amazed at how fast and smooth my expensive upgrade was, but after starting to use Docker, things changed for the worse.
I assume (and I may well be wrong) that something is going on when running Docker on M1 macs.
My recent switch to vim from WebStorm was in hopes of preserving as much RAM as I could (WebStorm typically used 2~3GB of RAM on my machine) to prevent the bursts of slugginess.