How do I connect two images in a network?

Have you checked the doc?

Did you check the Docker “Getting started” or any other tutorial?