Owing to the potential for fast deployment, containerization technology has been widely used in web applications based on microservice architecture. Online container placement aims to improve resource utilization and meet other service quality requirements of cloud data centers. Most current heuristic and hyper-heuristic methods for container placement rely on single allocation rules, which are inefficient in heterogeneous cluster scenarios. Moreover, some container placement tasks often have similar characteristics (e.g., resource request types and physical machine types), but traditional single-task optimization modeling cannot exploit potential common knowledge, resulting in repeated optimization during resource allocation. Therefore, a new multi-task genetic programming method is proposed to solve the online multi-objective container placement problem (MOCP-MTGP). This method considers selecting appropriate allocation rules according to the types of resource requests and cluster status. MOCP-MTGP can automatically generate multiple groups of allocation rules from historical workload patterns and different cluster states, and capture the similarities between all online tasks to guide the transfer of general knowledge during optimization. Comprehensive experiments show that the proposed algorithm can improve the resource utilization of clusters, reduce the number of physical machines, and effectively meet resource constraints and high availability requirements.