The strong-coupling regime of cavity quantum electrodynamics (QED) represents the light-matter interaction at the fully quantum level. Adding a single photon shifts the resonance frequencies-a profound nonlinearity. Cavity QED is a test bed for quantum optics1-3 and the basis of photon-photon and atom-atom entangling gates4,5. At microwave frequencies, cavity QEDhas had a transformative effect6, enabling qubit readout and qubit couplings in superconducting circuits. At optical frequencies, the gates are potentially much faster; the photons can propagate over long distances and can be easily detected. Following pioneering work on single atoms1-3,7, solid-state implementations using semiconductor quantum dots are emerging8-15. However, miniaturizing semiconductor cavities without introducing charge noise and scattering losses remains a challenge. Here we present a gated, ultralow-loss, frequency-tunable microcavity device. The gates allow both the quantum dot charge and its resonance frequency to be controlled electrically. Furthermore, cavity feeding10,11,13-17, the observation of the bare-cavity mode even at the quantum dot-cavity resonance, is eliminated. Even inside the microcavity, the quantum dot has a linewidth close to the radiative limit. In addition to a very pronounced avoided crossing in the spectral domain, we observe a clear coherent exchange of a single energy quantum between the 'atom' (the quantum dot) and the cavity in the time domain (vacuum Rabi oscillations), whereas decoherence arises mainly via the atom and photon loss channels. This coherence is exploited to probe the transitions between the singly and doubly excited photon-atom system using photon-statistics spectroscopy18. The work establishes a route to the development of semiconductor-based quantum photonics, such assingle-photon sources and photon-photon gates.