We study the mean first passage time (MFPT) to an absorbing target of a one-dimensional Brownian particle subject to an external potential v(x) in a finite domain. We focus on the cases in which the external potential is confining, of the form v(x)=k∣x−x0∣n/n, and where the particle's initial position coincides with x0. We first consider a particle between an absorbing target at x=0 and a reflective wall at x=c. At fixed x0, we show that when the target distance c exceeds a critical value, there exists a nonzero optimal stiffness kopt that minimizes the MFPT to the target. However, when c lies below the critical value, the optimal stiffness kopt vanishes. Hence, for any value of n, the optimal potential stiffness undergoes a continuous "freezing" transition as the domain size is varied. On the other hand, when the reflective wall is replaced by a second absorbing target, the freezing transition in kopt becomes discontinuous. The phase diagram in the (x0,n)-plane then exhibits three dynamical phases and metastability, with a "triple" point at (x0/c≃0.17185, n≃0.39539). For harmonic or higher order potentials (n≥2), the MFPT always increases with k at small k, for any x0 or domain size. These results are contrasted with problems of diffusion under optimal resetting in bounded domains.