This article studies a time-varying version of the so-called containment problem with collision avoidance for multiagent systems. The proposed control strategy is decentralized, since agents have no global knowledge of the goal to achieve, knowing only the position and velocity of a subset of agents. This control strategy allows a subset of mobile agents (called leaders) to track a prescribed trajectory while they achieve a time-varying formation. Simultaneously, another subset of mobile agents (called followers) converge exponentially to the region bounded by the leaders. For the collision avoidance, we added a repulsive vector field of the unstable focus type to the time-varying containment control law. Formation graphs are used to represent interactions between agents. The results are presented for the front points of differentialdrive mobile robots. The theoretical results are verified by numerical simulation. Additionally, an experimental case study is presented.