To paraphrase JWZ...
"Some people, when confronted with a dependency problem, think 'I know, I'll use Docker.' Now they have two problems."
Unfortunately there's no single answer. Static libraries vs. dynamic? Global install or packages from a repo? Everything depends on the degree of control you have over the deployment environment.