I do not believe the current answers correctly produce the result you appear to be after (which seems to be a "stars and bars" representation).
This would be one way to do this:
bincnts = (Join[{0}, PositionIndex[#][0], {Length[#] + 1}] //
Rest[#] - 1 - Most[#] &) &;
To illustrate the difference, I'll use the currently most upvoted answer (though a spot check on another answer yields the same):
All possible configurations with two dividers (hence 3 bins) (N.B.: I've used zero instead of 2 as the divider):
test = Permutations[{0, 0, 1, 1, 1, 1, 1}]
{{0,0,1,1,1,1,1},{0,1,0,1,1,1,1},{0,1,1,0,1,1,1},{0,1,1,1,0,1,1},{0,1,1,1,1,0,1},{0,1,1,1,1,1,0},{1,0,0,1,1,1,1},{1,0,1,0,1,1,1},{1,0,1,1,0,1,1},{1,0,1,1,1,0,1},{1,0,1,1,1,1,0},{1,1,0,0,1,1,1},{1,1,0,1,0,1,1},{1,1,0,1,1,0,1},{1,1,0,1,1,1,0},{1,1,1,0,0,1,1},{1,1,1,0,1,0,1},{1,1,1,0,1,1,0},{1,1,1,1,0,0,1},{1,1,1,1,0,1,0},{1,1,1,1,1,0,0}}
Current answer results:
Table[StringLength /@ StringSplit[l, "0"], {l,
StringJoin @@@ (Map[ToString, test, {2}])}]
{{5},{1,4},{2,3},{3,2},{4,1},{5},{1,0,4},{1,1,3},{1,2,2},{1,3,1},{1,4},{2,0,3},{2,1,2},{2,2,1},{2,3},{3,0,2},{3,1,1},{3,2},{4,0,1},{4,1},{5}}
bincnts results:
bincnts /@ test
{{0,0,5},{0,1,4},{0,2,3},{0,3,2},{0,4,1},{0,5,0},{1,0,4},{1,1,3},{1,2,2},{1,3,1},{1,4,0},{2,0,3},{2,1,2},{2,2,1},{2,3,0},{3,0,2},{3,1,1},{3,2,0},{4,0,1},{4,1,0},{5,0,0}}
Note that the latter correctly accounts for the actual number of bins that must logically be present.
Compared to using stringsplit or total on list split, this is quite performant:

with considerable advantage on large cases:

BINDIVIDER
is found at the beginning and/or end of the list, you should state if you are assuming that there are always "invisible"BINDIVIDER
's at the beginning and end of the list. Or, if true, (and I think equivalently) that $n$BINDIVIDER
's means that there are $n+1$ bins. $\endgroup${BINDIVIDER,ball,ball,BINDIVIDER}
should result in{2}
or{0,2,0}
? $\endgroup$