Kyle Fielding admitted possessing the noxious gas at High Peak Magistrates’ Court last Wednesday.
The 18-year-old was stopped by police while cycling with a friend on Woolley Bridge Road, Hadfield, at about 5.15am on August 10.
Fielding, of Litton Bank, was seen to drop a black can, marked Bodyguard, on the floor which officers later identified as a chemical weapon.
The court heard the defendant carried the aerosol for his own protection but had never used it.
Fielding was sentenced to six weeks in prison, suspended for 12 months.
He was also ordered to a pay an £80 victim surcharge and £85 costs.