Vincent Murphy (61) was so addicted to alcohol that he was advised against stopping drinking completely as that would be worse for him.
Judge Michael Walsh gave him a two-month suspended sentence.
Murphy, with an address at homeless accommodation on Thomas Street, pleaded guilty to threatening, abusive and insulting behaviour and public drunkenness.
Dublin District Court heard that last August 24, gardaí were called to St James's Hospital emergency department, where Murphy was lying on the ground and refusing to leave after being discharged.
He was slurring, unsteady on his feet and was so drunk he was a danger to himself.
Gardaí were called to St Helena's Road in Finglas the following day.
Murphy was refusing to get off a bus, was abusive to gardaí and members of the public and refused to follow garda directions.
He had 205 previous convictions, including 41 for public order offences, as well as criminal damage and other charges.
The accused had been plagued by alcohol addiction all his life, his barrister Anne Sheridan said.
He apologised to the hospital, gardaí and Dublin Bus for his behaviour, which was not something he would engage in when sober, Ms Sherdian said.
It had been a "particularly bad time" for him and he had been drinking heavily.
He was waiting for a place in a detox programme, but had not stopped drinking entirely.
Murphy had been advised not to because the level of his addiction meant it would be worse for him.
He had a heart condition, was on a cocktail of medication and required a walking aid to get around.
"It seems to me if this gentleman doesn't give up the drink, the drink will give him up," Judge Walsh said.
He suspended the sentence for two years.