First create an overlay network:
docker network create -d overlay uber-net
Now deploy two stacks:
docker stack deploy -c docker-compose-1.yml foo
docker stack deploy -c docker-compose-2.yml bar
The configs are included.
Connect to the foo
service:
docker exec -it foo_foo.1.xxx sh
Try to ping the bar
service from the container:
ping bar
Both bar
and bar_bar
work for me.