We extend a model for the morphology and dynamics of a crawling eukaryotic cell to describe cells on micropatterned substrates. This model couples cell morphology, adhesion, and cytoskeletal flow in response to active stresses induced by actin and myosin. We propose that protrusive stresses are only generated where the cell adheres, leading to the cell's effective confinement to the pattern. Consistent with experimental results, simulated cells exhibit a broad range of behaviors, including steady motion, turning, bipedal motion, and periodic migration, in which the cell crawls persistently in one direction before reversing periodically. We show that periodic motion emerges naturally from the coupling of cell polarization to cell shape by reducing the model to a simplified one-dimensional form that can be understood analytically.