We start by analyzing experimental data of Spinelli [A. Spinelli, M. A. Torija, C. Liu, C. Jan, and C. Leighton, Phys. Rev. B 81, 155110 (2010)] for conductivity of $n$-type bulk crystals of SrTiO$_3$ (STO) with broad electron concentration $n$ range of $4times 10^{15}$ - $4 times10^{20} $ cm$^{-3}$, at low temperatures. We obtain good fit of the conductivity data, $sigma(n)$, by the Drude formula for $n geq n_c simeq 3 times 10^{16} $ cm$^{-3}$ assuming that used for doping insulating STO bulk crystals are strongly compensated and the total concentration of background charged impurities is $N = 10^{19}$ cm$^{-3}$. At $n< n_c$, the conductivity collapses with decreasing $n$ and the Drude theory fit fails. We argue that this is the metal-insulator transition (MIT) in spite of the very large Bohr radius of hydrogen-like donor state $a_B simeq 700$ nm with which the Mott criterion of MIT for a weakly compensated semiconductor, $na_B^3 simeq 0.02$, predicts $10^{5}$ times smaller $n_c$. We try to explain this discrepancy in the framework of the theory of the percolation MIT in a strongly compensated semiconductor with the same $N=10^{19}$ cm$^{-3}$. In the second part of this paper, we develop the percolation MIT theory for films of strongly compensated semiconductors. We apply this theory to doped STO films with thickness $d leq 130$ nm and calculate the critical MIT concentration $n_c(d)$. We find that, for doped STO films on insulating STO bulk crystals, $n_c(d)$ grows with decreasing $d$. Remarkably, STO films in a low dielectric constant environment have the same $n_c(d)$. This happens due to the Rytova-Keldysh modification of a charge impurity potential which allows a larger number of the film charged impurities to contribute to the random potential.