In an approach for optimally grouping containers, a processor passively monitors a set of parameters for a set of containers within a network. A processor records the set of parameters for each container of the set of containers. A processor deploys a k-nearest neighbor neural network (KNN) to determine a first set of groupings of the set of containers based on the set of parameters. A processor simulates the network having grouped containers based on the first set of groupings of the set of containers output by the KNN. A processor simulates an action on the set of containers. A processor updates a reward function based on the action. A processor determines whether a maximum value of the reward function is reached.