Docker container and their IPs on overlay (swarm) networks
When you ping nginx the docker swarm returns Virual IP of swarm service named "nginx" not the container ip. 

This is is how internal load balancer works - you can have multiple replicas of "nginx" containers behind the "nginx" service.