简体   繁体   中英

docker - Azure Container Instance - how to make my container accesable and recognized from outside?

I have windows container which should access to external VM database (that is not in container, lets say VM1) so I would define for them l2bridge network driver in order to use the same Virtual Network.

docker network create -d "l2bridge" --subnet 10.244.0.0/24 --gateway 10.244.0.1 
-o com.docker.network.windowsshim.vlanid=7 
-o com.docker.network.windowsshim.dnsservers="10.244.0.7" my_transparent

So I suppose we need to stick on this definitely. But now as well I need to make my container accessible from outside, on port 9000, from other containers as well as from other VMs. I suppose this has to be done based on its name (host name) since IP will be changed after the each restart. How I should make my container accessible from some other VM2 virtual machine - Should I do any modifications within the network configuration? Or I just to make sure they are both using the same DNS server? Of course I will do the expose of the port, but should I do any kind of additional network configuration in order to allow traffic on that specific port? I've read that by default network traffic is not allowed and that Windows may block some thing.

I will appreciate help on this. Thanks

It seems you do not use the Azure Container Instance, you just run the container in the Windows VM. If I am right, the best way to make the container accessible outside is to run the container without setting the network, just need to map the port to the host port. Then the container is accessible outside with the exposed port. Here is the example command:

docker run --rm -d -p host_port:container_port --name container_name image

Then you can access the container outside through the public IP and the host port of the VM.

Update:

Ok, if you use the ACI to deploy your containers via docker-compose, then you need to know that ACI does not support the Windows container in VNet. It means Windows containers cannot be created with private IP in the VNet.

And if you use the Linux container, then you can deploy the containers in a VNet, but you need to use the follow the steps here . Then the containers have private IPs and it's accessible in the VNet through that private IPs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM