Underground hydrogen reservoirs, whose existence has been confirmed recently by geologists all over the world, represent a new source of renewable energy. Hydrogen is formed as the product of reaction of serpentinization between ferromagnesian minerals of the Mantle and water in the offshore zones of subduction or in continental zones at considerable depth beneath hydrothermal aquifers. Initially dissolved in water, hydrogen can create free gas bubbles when the local concentration of H2 dissolved in water exceeds the equilibrium value. The bubbles raise up and create the gas cap of free hydrogen. This process is significantly influenced by methanogen bacteria inhibiting in aquifers and consuming hydrogen for their metabolism. The reactions initiated by bacteria leads to the appearance of other volatile components as methane. The dimension, the form of the gas cap and the concentration of hydrogen and methane determine the efficiency of gas production and the energy potential of the reservoir. In the present paper we develop the conceptual mathematical model of gas cap formation in hydrogen reservoir. The bacterial activity is described by the equation of population dynamics with specific kinetic functions obtained by the authors by treating experimental data. The formation of free gas is modelled in terms of the formation of oversaturated nuclei, their growth and simultaneous motion of isolated bubbles. As far as the bubbles grow, they stick together and create continuous free gas. Thus, the hydrogen motion consists of two stages: (i) the motion of isolated bubbles, controlled by the equations of ganglion dynamics; and (ii) the motion of continuous gas through water, governed by Darcy’s law. The bubble growth is ensured by the mass exchange with hydrogen dissolved in water, which involves a non-equilibrium in the average hydrogen concentrations. Such a problem of hydrogen raising is solved analytically in simplified situation without bacteria. The problem can be reduced to a system of nonlinear hyperbolic equations, which has either continuous or discontinuous solutions (shock waves) depending on the degree of the non-equilibrium. Multiples deformations of the shocks under gas raising are described. The impact of bacteria is studied numerically by using the open source Basilisk (developed by D’Alembert Institute). We have revealed non trivial scenarios of the appearance of piece-wise constant traveling waves, or auto-oscillations caused by the nonlinear population dynamics. The result obtained enables us to give estimation to the characteristic time of gas cap formation and the evolution of its composition in time.