I have 2 containers created via docker compose with the following settings:
docker-compose.yml File:
version: "3.7"
services:
web:
image: img_web
container_name: cont_web
svcs:
image: img_svcs
container_name: cont_svcs
depends_on:
- web
Dockerfile for img_web:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
WORKDIR /inetpub/wwwroot
Dockerfile for img_svcs:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
WORKDIR /inetpub/wwwroot
After docker-compose up -d
, and from cont_svcs container, I'm able to:
Ping cont_web by IP
Ping cont_web by hostname (container id: bf4001be1e84 autogenerated.)
BUT I CAN'T Ping the cont_web container by its alias (web)
I inspected both containers, I can see in the network sections the following:
"Networks": {
"test_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"bf4001be1e84",
"web"
],
...
Both containers are connected to the 'test_default' driver.
NB: Even I can't ping the web machine by its "web" alias name within the machine itself.
I would greatly appreciate your help and feedback.
Thanks Sam
That's because Netbios resolution works for primary name. you can try to add 2nd Netbios name through registry: https://www.techrepublic.com/blog/the-enterprise-cloud/adding-multiple-netbios-names-for-windows-servers/
alternatively i'd recommend make a 2nd Cname record in DNS and doing the resolution with static names (might not be acceptable to you for your docker containers)