Working with Docker Windows Containers I want to go beyond only one Docker container running a App. As described in the Microsoft docs under the headline "Docker Compose and Service Discovery":
Built in to Docker is Service Discovery, which handles service registration and name to IP (DNS) mapping for containers and services; with service discovery, it is possible for all container endpoints to discover each other by name (either container name, or service name).
And because docker-compose lets you define services in it´s yaml files, these should be discoverable (e.g. pingable) by there names (be sure to remind the difference between services and containers in docker-compose). This blog post by Microsoft provides a complete example with the service web
and db
including full source with the needed docker-compose.yml in the GitHub repo.
My problem is: the Docker windows containers do "find" each other only sometimes, and sometimes not at all. I checked them with docker inspect <container-id>
and the alias db
and web
are present there. But when I powershell into one container (e.g. into one web container via docker exec -it myapps_web_1 powershell
) and try to do a ping db
this only works only occasionally.
And let me be clear here (because IMHO the docs are not): This problem is the same for non docker-compose scenarios. Building an example app without compose, the problem also appears without docker-compose services, but just plain old container names!
Any ideas on that strange behavior? For me this scenario gets worse with more apps coming into play. For more details, just have a look into https://github.com/jonashackt/spring-cloud-netflix-docker, where I have an example project with Spring Boot & Spring Cloud Eureka/Zuul and 4 docker-compose services, where the weatherbackend and weatherbackend-second are easily scalable - e.g. via docker compose scale weatherbackend=3
.
My Windows Vagrant box is build via packer.io and is based on the latest Windows Server 2016 Evalutation ISO. The necessary Windows Features and Docker/docker-compose installation is done with Ansible.
Having no fix for this problem, Docker Windows Containers become mostly unusable for us at the customer.