According to officials familiar with military affairs, an aircraft carrier is exposed to "the highest risk when it enters or leaves a port" because it cannot move quickly and its aircraft cannot be used.
Why can't a carrier's planes be used in port?
Simple. An aircraft carrier must turn into the wind at high-speed to get sufficient wind over the flight deck to launch & recover aircraft. If you can get say 30 knots across the deck, that's 30 knots extra speed as 'seen' by the aircrafts wings. More lift. Even with steam catapults this is still necessary.
Typically the carriers air wing component flys off to a naval air station prior to the carrier entering port. The only aircraft useable in port would be helicopters.