Here is a method which should give you what you want, but I leave the details to you as I don't have time to work them out now.
Without loss of generality we may work over an algebraically closed field. Each singular fibre consists of a union of two $(-1)$-curves meeting at a single point. Contracting a choice of $(-1)$-curve in each single fibre, we obtain a ruled surface over $\mathbb{P}^1$. There is a formula for the canonical divisor of a ruled surface, which when combined with the formula for the canonical divisor of a blow-up, should give you what you want (all these tools can be found in Ch. V of Hartshorne).
Note that a useful check is given by Noether's formula, which implies that
$$(K_X)^2 = 8 - \mbox{number singular of fibres}.$$