Ships generate a fair amount of garbage and trash (which our cousins in the Royal Navy refer to as "gash"). In port, it was handled as any other business would; it was thrown into a dumpster on the pier.
I don't know how the Navy handles garbage and trash at sea now. Submarines supposedly compacted it and then ejected it overboard, so it would sink. Back in the day, surface ships would just throw it from the fantail; naval ships pretty much left a stream of garbage bags floating in their wakes. 
When a ship was at an anchorage, typically a civilian firm would be contracted to come by the ship once or twice a day to pick up the garbage. In some countries, a garbage lighter from a local navy base would do the honors and there would be impromptu trading of goods between the sailors on the warship and the crew of the lighters. The lighters were supposed to take the garbage ashore and then it would be trucked to the local dump.
In Italy, of course, it didn't work that way. The garbage lighters would wait until it was completely dark. Then they would go several miles out to sea and throw all of the shit over the side. This often had one bad diplomatic ramification: Garbage with papers bearing the name of the USS UMPTECLUTCH would then drift ashore onto beaches favored by tourists. The mayor of that town would either complain to his foreign ministry or sometimes just call the local consulate directly and scream at the consular officials about American ships fouling his pristine beaches.
That usually resulted in a cable going to Foggy Bottom, which then was passed along to Fort Fumble. Some desk-bound captain or admiral would then send a message of inquiry to the offending ship, with the message copied to the commanders of the Second Fleet, the Sixth Fleet, the home cruiser-destroyer group, CTF 60, CTG 60.1 (or 60.2) and the home destroyer squadron. That was usually answered with a message that explained that garbage services were contracted through the local consular agent, or "we did what we were supposed to, whaddaya want from us?"
So one time (probably more than one time), there was an American naval ship anchored a mile or so off the coast of an Italian town. Garbage services were arranged as I described above. The garbage was handled by the lightermen as I also described. There were currents that took the garbage from where it was dumped into the Mediterranean Sea (more precisely, the Tyrrhenian Sea) back towards that town.
And back towards that ship.
When the garbage had floated back towards that ship, the garbage bags had taken on water. Some of them had submerged and were floating along about twenty or so feet under the surface. That put them right at the level of the sea chests for the generators, the evaporators and the fire mains. The suction from the sea chests sucked the garbage into the sea chests, where the garbage clogged the inlet screens.
All that stuff kept tripping offline as cooling was lost. The cure was to connect a fire hose to the sea chest and backwash the shit back out. The chief engineer and the captain soon realized that the time might come when all of the firemain pump inlets were clogged at the same time. So the captain ordered that the Sea and Anchor Detail be set, the anchor was hauled up and the ship headed out to sea.
This happened around midnight or so, stranding several dozen sailors ashore. After it was fully light out, the ship came back in, though well away from the garbage current and sent in its boats to retrieve the rest of the crew. The boat crews were told to keep a watch out for garbage so that the sea chests for their engines weren't fouled.
In due course, the sailors who were ashore were recovered and the ship went off to its next mission.
 Classified material was put into burn bags. Stuff classified as "secret" or above was supposed to first be shredded and then burned.
 In Muslim nations, a very desired trade good by the lightermen was American porn.
 A "sea chest" is the point of salt water inlet for a given system. For generators, sea water was used for cooling the condensers and sea water also cooled the air-conditioning plants. For evaporators, sea water was the raw material for making fresh water. Water for fire-fighting was also sea water.
Oh, the irony...
11 hours ago