Most bigger boats have a holding tank for grey water and a water tank for fresh water. When you shower you use the fresh water and dump it into the harbour, it's not that dirty just because you've showered. When you go to the toilet you use saltwater to flush and flush it into the greywater tank, which you can then empty either by having it sucked out (All European ports are required by law to have equipment for doing so, though many don't) or dump it into the ocean once you're more than 12 miles off the coast.
Simple :-)