The boxes are each containers of uniquely colored balls. So, to get two balls of the same color, two boxes need to be opened.
or
The boxes are each a container of uniquely colored balls. So, to get two balls of the same color, two boxes need to be opened.
The meaning is perfectly clear in both passages but to justify either grammatically would take a whole troupe of devious pin-dancers and still, both would be so hideously unidiomatic it’s almost certain they’re unreal contrivances for theoretical study.
The real options would be The boxes are containers/ … contain or Each box is a container/ … contains
Either way both need to be… suits two. Two boxes need to be… works for more.
– Robbie Goodwin Jun 26 '17 at 14:05