Buckling of peapods, fullerenes and nanotubes