Pikmin colonies are just a group of Pikmin living on an onion, to create one yourself you just need Pikmin inside a sitting onion, then just let them come out of it on their own (Use the whistle on the onion or use the onion interface, check the section about the onion controls.

If you allow it, is daytime, the onion is sitting, on the ground, and is not inside the water (unless is a blue onion) Pikmin inside the onion will start to exit and roam around, a max of 20 Pikmin per onion can be outside at a time. while the rest remain inside (you can still take as much as you want and have from inside the onion to your inventory)

Pikmin that exit the onion in their own will roam around inside a 16-block radius from their onion and will prioritize to remain inside that radius over anything else, so there's no need for fences and such to keep them inside an area, but you might still want them to keep dangers outside the area, they'll roam around their onion during the day and return to the onion in the night.
Pikmin from colonies are targeted by all hostile entities besides creepers and will attack back in group if one is hit, This can be good or bad depending on the number of Pikmin, but they are not likely to encounter many hostile creatures unless you force it since they don't come out at night, besides that the only other common danger they might face is water, but they actively avoid it, even if you locate the onion on a miniature island they'll just stay on solid ground, so unless you and pour water over them directly you shouldn't worry for them drowning in your crops or something.

Is important to remark that Pikmin living in an onion that are outside will ignore your whistle due to not being considered on your squad, If you wanna use them, make them enter the onion and withdraw them from there, or if you have over 20 just take the ones staying inside the onion.
And as a last note, 

§dAutomtic Pikmin farming§r

Besides just having your Pikmin chilling around, having a Pikmin colony allows for the Pikmin to reproduce themselves given the right resources, is all based on these points:

-Pikmin from colonies automatically harvest pellet posies of their color inside the 16-block radius around the onion.

-Enemies they kill can still drop crystallized nectar even if you don't command them

-They will bring any crystallized nectar and pellets of their color to the onion for it to absorb them.

-They unpluck fully grown Pikmin of their color that then join the colony.

By just placing some pellet posies near the colony, or a constant stream of hostile mobs the Pikmin can handle, they can reproduce by themselves, the excess Pikmin will stay in the onion and you can withdraw them later when needed.