I think the only way Joab stayed on as general was because he had the loyalty of the common soldiers. Joab and David despised each other, even more so after the debacle with Absolom. Joab had all the information to blackmail David as well, which is why David never sacked him after the murders of Abner and Amasa.
I think David feared Joab, because of his ruthlessness.
That is why be basically told young Solomon to get rid of Joab ASAP...............
I’ve always inferred that, aside from the threat of being blackmailed by Joab, David feared him, physically. He didn’t fear Goliath, but he feared Joab’s murderousness, Saul’s insanity, and Nathan’s disapproval.