A drunken man had to be pepper-sprayed after he tried to grab a garda by the throat, pulling off the officer's tie.
Thomas O'Donoghue (53) became violent as he was being arrested for shouting abuse at passers-by for "no reason".
Judge Mary Cashin adjourned the case for a probation report.
O'Donoghue, of no fixed address, pleaded guilty to public drunkenness and breach of the peace.
Dublin District Court heard gardai saw O'Donoghue spitting and roaring at members of the public on Westmoreland Street at 8.05pm on October 19, 2017.
He was apparently being extremely abusive and insulting for no apparent reason.
When approached, he attempted to seize a garda by the throat, but grabbed his tie, pulling it off. He violently resisted arrest and had to be pepper-sprayed.
A garda witness said there was no injury, and the officer had been wearing a clip-on tie which "simply came off".
Gardai also arrested the accused on O'Connell Street at 4.10am on November 25, 2017.
He was approaching members of the public in a threatening manner with his fists clenched, taunting and insulting them.
The accused was a steelworker who had been out of work on disability, his barrister Conor Burke said.
His wife died and this caused him to drink more heavily.
"You cannot blame every- thing on drink," the judge said. Trying to grab the garda's throat was "not just messing," she added.