We present results of a simulation study of a fluid of hard spherocylinders with a length-to-diameter ratio of 15 in contact with a planar hard wall and confined by two parallel hard walls. A Monte Carlo method is developed for simulating fluids in contact with a single wall. Using this method, we find a transition from a uniaxial to a biaxial surface phase, followed, at larger bulk densities, by the formation of a thick nematic film, with the director parallel to the wall, at the wall-isotropic fluid interface. As the density far from the wall cb approaches the value at bulk isotropic-nematic coexistence cI, the thickness of the nematic film appears to increase as -ln(cI-cb). For a fluid confined by two parallel hard walls, a first-order capillary nematization transition is found. The phase equilibria are determined by Gibbs ensemble Monte Carlo simulations for several wall separations. The difference in the coexisting densities of the capillary condensed nematic and isotropic phases becomes smaller upon decreasing the wall separation, and no capillary nematization transition is found when the wall separation is smaller than about twice the length of the spherocylinders. These features imply that the capillary nematization transition ends in a capillary critical point at a critical wall separation. Our simulation results are fully consistent with the findings of our recent theoretical study of the Zwanzig model for a hard-rod fluid.