Acoustic traps are used to capture and handle suspended microparticles and cells in microfluidic applications. A particular simple and much-used acoustic trap consists of a commercially available, millimeter-sized, liquid-filled straight glass capillary actuated by a piezoelectric transducer. Here, we present a three-dimensional numerical model of the acoustic pressure field in the liquid coupled to the displacement field of the glass wall, taking into account mixed standing and traveling waves as well as absorption. The model explains the dynamical mechanism that leads to the formation of localized acoustic resonance modes in such a straight acoustic waveguide without any geometrical cavities in the axial direction of the capillary. The model further predicts that some of these modes are well suited for acoustic trapping, and it provides estimates for their frequencies and quality factors, the magnitude of the acoustic radiation force on a single test particle as a function of position, and the resulting acoustic retention force of the trap. We show that the model predictions are in agreement with published experimental results, and we discuss how improved and more-stable acoustic-trapping modes might be obtained using the model as a design tool.