US forces struck Iranian coastal targets after Tehran was accused of attacking a commercial cargo ship in the Strait of Hormuz.