Ship help

Hi guys quick question so when on ship as an engineer apprentice can you leave the boat and explore when you are in port? Like lets say you stopped at mexico could you roam before you leave again?
Your visit to foreign ports is usually 4 days one of which you will probably be duty and required to remain on board, and leave is usually granted from about midday or in some cases earlier.