The equilibrium density distribution and thermodynamic properties of a Lennard-Jones fluid confined to nanosized spherical cavities at a constant chemical potential was determined using Monte Carlo simulations. The results describe both a single cavity with semi-permeable walls as well as a collection of closed cavities formed at the constant chemical potential. The results are compared to calculations using classical density functional theory (DFT). It is found that the DFT calculations give a quantitatively accurate description of the pressure and structure of the fluid. Both theory and simulation show the presence of a 'reverse' liquid–vapor transition whereby the equilibrium state is a liquid at large volumes but becomes a vapor at small volumes.