Composting barrels are obtained as a rare reward from doing the naturalist quest.
To begin the quest you must talk to Matthias the naturalist who can be found inside Britain public library in Trammel. The naturalist will give you the quest 'study the solen hive', you must then go to the solen hive and study the 4 nests which can be found inside (5th nest optional accessed with a green thorn planted in sand). On completion return to Matthias who will reward you with either a rare seed or a composting barrel.
Once you have your composting barrel you will need to lock it down in your house, then you can drop seeds or plants onto the barrel for a reward.
You will be rewarded with either fertile dirt, Magic Fertilizer, a coffee plant, or a fruit plant deed.