The air that is inside a ship is much less dense than water. when a ship is set in water, it pushes down and displaces an amount of water equal to its weight.
The reason that most rocks sink is because of the law of buoyancy, which is all about how things float or sink. An object will float if it displaces as much water as it weighs.