We present the results of a search for short-duration gravitational-wave transients in the data from the second observing run of Advanced LIGO and Advanced Virgo. We search for gravitational-wave transients with a duration of milliseconds to approximately one second in the 32-4096 Hz frequency band with minimal assumptions about the signal properties, thus targeting a wide variety of sources. We also perform a matched-filter search for gravitational-wave transients from cosmic string cusps for which the waveform is well modeled. The unmodeled search detected gravitational waves from several binary black hole mergers which have been identified by previous analyses. No other significant events have been found by either the unmodeled search or the cosmic string search. We thus present the search sensitivities for a variety of signal waveforms and report upper limits on the source rate density as a function of the characteristic frequency of the signal. These upper limits are a factor of 3 lower than the first observing run, with a 50% detection probability for gravitational-wave emissions with energies of ∼10-9 Mc2 at 153 Hz. For the search dedicated to cosmic string cusps we consider several loop distribution models, and present updated constraints from the same search done in the first observing run.