Multi-agent modeling is a challenging issue in intelligent systems, which is further compounded by heavy and complex traffic in maritime contexts. Trajectory forecasting can enhance operation safety. Nonetheless, effectively modeling interactions among vessels poses a significant difficulty. Towards this end, we propose a conditional variational autoencoder approach to ship trajectory prediction in a dynamic and multi-modal encounter situation. Leveraging a shared Recurrent Neural Network architecture and attention mechanism, our method aggregates vessel trajectory data, enabling the model to learn and encapsulate meaningful encounter information across active vessels. We utilize Automatic Identification System data from the Oslofjord region to validate our approach. Through comprehensive experiments conducted on a four-ship encounter dataset, our proposed model demonstrates promising performance, by outperforming the benchmark models. Furthermore, we analyze the prediction model in a wide array of dimensions, showcasing its proficiency in complex ship behaviours learning, modeling ship interaction and approximating actual trajectories.