In order to solve the problems of optimizing production and transportation systems, a clustering procedure for objects is suggested. The procedure is a universal methodology for dividing a set of objects into subsets with their centers possessing optimal properties. At the same time, the use of point proximity metrics used in cluster analysis models the minimization of distances during transportation. If the volume of produced/extracted containerisable products of a production point is considered as the “weight” of each point, than the problem of minimizing transportation costs can be solved as a problem of optimizing clusters and their centers. A set of analytical models has been developed to describe and optimize the choice of location and number of container terminals (CT) at the first level and container storage and distribution centers (СSDC) at the second level of a two-level terminal model and logistics infrastructure of the container transport system (CTS). New clustering algorithms are suggested to determine the locations of CT and СSDC based on the condition of minimizing transportation costs and creating a terminal and logistics infrastructure, taking into account given or random number of clusters.