"This means skippers must not navigate 500 metres in front of and 50m either side of large ships," Peters said.
"We had a patrol boat in the area and the skipper of the yacht was spoken to after the incident."
Eyewitness Chris Cousins and his family were walking down the 4WD track of Mauao when they heard the ship sounding its horn.
"As we rounded the corner I could see a little white yacht sailing along in the channel at the same time as the container ship was entering the harbour," Cousins said.
"Then I saw the ship take a hard right turn heading towards Matakana Island to avoid hitting the yacht. The ship seemed to veer off its course at a funny angle.
"I thought: 'Crikey, someone's in all sorts of trouble' but I couldn't see anybody on the deck of the white yacht."
After the "close-call" the yacht sailed away and, after going around the yacht, the ship continued its entry.
"It's extremely lucky, hugely lucky in fact, that the ship was able to change direction in time ... I estimate the closest point between the two vessels before the ship veered off course was less than 100 metres."
Under maritime law, the skipper has been fined the maximum amount of $200.