Capability is a certain ability, the quality of being capable, a potential aptitude.
Capacity is the ability to contain, that is: volume or amount that fits in a certain container for example. The maximum amount that something can contain.
It is also a certain rank: He/she was employed in the capacity of merchandising designer.
There´s other meanings, some are legal jargon, like "the Parliament´s capacity to create new laws", that means, legal competence exerted by a certain person or institution.
"Capacity" can also mean ability but implies that one "contains" (so to speak) the ability to do something. Example: You have the capacity to succeed. This suggests a metaphorical space that one has - that could "contain" success - but basically means that one has the potential to succeed - for whatever reason. You could also say "you have the capability to succeed" but that refers more to the physical, mental, or cognitive ability or skill that one has to succeed rather than the idea of an opportunity or chance to succeed.
And of course, "capacity" has the meanings that were already mentioned.