If you berth at the new port in Copenhagen which we did on our last cruise with Princess there is a local service bus put on specially for when cruise ships berth which drops you off in middle of Copenhagen and is cheaper than cruise line shuttle buses. Google and you will find all the details as it has been running for couple of years.
Tallin if you are able enough is only a short and very enjoyable walk from the market that is open at port for when ships are at berth.