We investigate how confinement may drastically change both the probability density of the first-encounter time and the related survival probability in the case of two diffusing particles. To obtain analytical insights into this problem, we focus on two one-dimensional settings: a half-line and an interval. We first consider the case with equal particle diffusivities, for which exact results can be obtained for the survival probability and the associated first-encounter time density over the full time domain. We also evaluate the moments of the first-encounter time when they exist. We then turn to the case when the diffusivities are not equal, and focus on the long-time behavior of the survival probability. Our results highlight the great impact of boundary effects in diffusion-controlled kinetics even for simple one-dimensional settings, as well as the difficulty of obtaining analytic results as soon as translational invariance of such systems is broken.