This article discusses an aspect of the most pressing problem of 2020, that of the spread of infectious diseases. The work considers a railway compartment coach as a particular object of spread of infectious diseases. The objective is to describe spread of the epidemic in a railway coach using a stochastic model. The model of the coach is represented as a network. The processes occurring on the network are considered to be Markov processes. In this paper, two methods of stochastic modelling are applied: modelling based on Kolmogorov equations and Gillespie algorithm. Kolmogorov equations are used to test applicability of Gillespie algorithm, which, in turn, is used to simulate the model of the coach. The obtained data were analysed, and based on that analysis it is possible to make a conclusion about applicability of the model to the case of a typical passenger train.