In this research, with the help of the recently developed ِِDung Beetle Optimizer (DBO) algorithm, the main dimensions of container ships in terms of their loading capacity and their speed with the aim of minimum hydrodynamic resistance along with several constraints such as permissible range of main dimensions, hydrostatic stability, and specified underwater volume, has been optimized. For this purpose, the governing equations were extracted from Holtrop's experimental method. For verification, the results obtained from the DBO algorithm were compared with the results of the Optimization library of Maple software. The optimization results on the dimensions of a container ship with a capacity of 1000 TEU showed that the hydrodynamic resistance of the optimized ship at a speed of 15 knots can be reduced by about 14% and at a speed of 19 knots by about 21%. Also, in constant displacement, with the increase of the vessel speed, the optimized vessel length increases, but its draft decreases. In particular, the purpose of this research is to introduce the capabilities of the DBO algorithm and its application in solving optimization problems in marine engineering.