Containers in the same network are linked to each other.
You have to create a network for those containers.
docker network create --driver bridge isolated_network
When running the containers, you have to specify the network.
docker run -it --net=isolated_network --name container1 container1-image bash
docker run -it --net=isolated_network --name container2 container2-image bash
after you created the containers you can ping other containers in the same network using just the name of the containers
root@container1 ping container2
root@container2 ping container1