Star Trek has shown a progression of Star Fleet through the series. Enterprise shows a very Nasa like component, While TOS is slightly more formal navy, and TNG era is strictly military format, even if they won't say it straight out. They have enlisted personal and commissioned officers. And they have their entire disciplinary process modeled after military tradition.
This includes marks on service records, demotions in rank, court martials, and finally discharges.
An example of a court martial is scene in the TNG episode Drum head, the meaning of which is a field court martial. And in one of the TOS movies, where Admiral Kirk is being court marshalled for his actions, and punished with a demotion to captain. An example of dishonorable discharge is seen in Voyager with Tom Paris.
Obviously Kirk meant fired in dark humor, making light of a dangerous situation as he always does (not mockingly or sarcastic, just a light hearted half joke).