I am very new to docker, this is the first time I’m using it and it’s for work.
I am running windows 11 and have created a new business central container.
Unfortunately, I am unable to access it through the hostname/bc URL. Instead, I must type in the IP adress/BC and only then it works.
Does anyone know how to fix this? I checked the hosts file in C:\Windows\System32\drivers\etc and I manually added the ip adress/hostname combination but it still doesn’t work.
An additional question is that the IP for my container keeps changing every time I start it up. Is there a way to keep it static? I thought this was a local container, why does it even have an IP address?
Please excuse if any of this is a dumb question, as I said this is the first time I’m using Docker. Ask any clarifying questions you may have.
The last link is (currently) about Docker Desktop which is Docker CE in a virtual machine whith a GUI.
If you share what you do actually, help can come faster, but using container names as hostnames works only with custom docker networks which Docker Compose creates by default. If you use the docker run command, you have to create a network with docker network create.
How else would you use a hostname to access a specific container and use the same port inside any container? ONe of the best features of containers is the network isolation.
You also seem to use Docker Desktop for Windows (am I right), but you opened the topic in the Docker Engine category which runs inside the virtual machine of Docker Desktop so you will need port mappings as well which is mapping a port from the host to a containers ip address in the VM. You can find more about docker networks in my tutorial website I linked above, or you can find it also on dev.to:
When I launch my app from VSCode it automatically opens up into stefan/BC. And I can’t even hardcode the IP because it changes every time I restart the container.
Container hostnames wouldn’t work from the host machine (outside containers) with Docker CE either and docker Desktop runs everything in a virtual machine, so even the container IPs are private in the VM, you can’t access them from the host. I worte about that too in linked blogpost. You need to forward ports from the host to the containers. You can also use a reverse proxy like Traefik or Nginx Proxy.