In this paper, with symbolic computation, a generalized variable-coefficient coupled Hirota–Maxwell–Bloch system is studied, which can describe the ultrashort optical pulse propagation in a variable-coefficient nonlinear, dispersive fiber doped with two-level resonant atoms. Integrable conditions of such system are determined via the Painlevé analysis and the associated Lax pair is explicitly constructed. Furthermore, the analytic one- and two-soliton-like solutions are derived by virtue of the Darboux transformation. Through the graphical analysis of the soliton-like solutions obtained, the propagation features of optical solitons and their interaction behaviors are discussed. Different from the previous results, the two-soliton interaction is found to admit the energy interchanging property.