Grenadier Guardsman Warren Butler, 19, of Carlisle, pled guilty to a charge of improper use of a communications network under section 127 of the Communications Act (2003).
Serena Edwards, prosecuting, told Basingstoke Magistrates' Court that Butler, who is based at Aldershot, Hampshire, had been drinking alone when he wrote the comment.
She said that after the comment went viral, Butler became concerned for his family and contacted police.
Ms Edwards said that in interview, he told police he had attended EDL marches in the past and had a racist background. She added that he also made comments about people of Eastern European backgrounds.
Ms Edwards said: "He said that he is from a racist background but not actively racist, he stated that if he knew the consequences he wouldn't have posted the comments."
Fabienne Macey, defending, said that Butler deleted the comment and his Facebook account after he realised the impact of it, which had led to him receiving death threats.
She said: "He has grown up in a racist family, his father and grandfather were actively racist. He has been brought up not to like people of a different race and that is all he has known until being 19 years old and recently joining the Army."
Sentencing Butler to a 16-week prison sentence suspended for 18 months and 250 hours community service, District Judge Philip Gillibrand said: "Everybody has said what a despicable thing this was to do and I agree wholeheartedly.
He spared the defendant jail to give him a chance to learn from his actions, which he said had been a result of him being "brain-washed" by propaganda and by his upbringing.
He added that Butler had brought disgrace upon the British Army.