The method for sterilizing containers, wherein a treatment head is guided into the interior of a container to be sterilized and the treatment head emits radiation in the interior of the container at least intermittently over a predefined time period (dT), wherein the container is moved relative to the treatment head in a longitudinal direction (L) of the container at least intermittently at a relative movement speed (v) over the predefined time period (dT). The relative movement speed (v) of the treatment head located in the interior of the container varies over the predefined time period and is controlled as a function of an internal profile of the container.