An ideal compressible fluid is considered, with an equilibrium density being a given function of coordinates due to presence of some static external forces. The slow flows in such system, which do not disturb the density, are investigated with the help of the Hamiltonian formalism. The equations of motion of the system are derived for an arbitrary given topology of the vorticity field. The general form of the Lagrangian for frozen-in vortex lines is established. The local induction approximation for motion of slender vortex filaments in several inhomogeneous physical models is studied.