Reputation: 1651
I have a window container with an asp.net webapi app (not core) and second (linux) container with an sql server.
In linux container I have created new network:
docker network create budget-app-network
and created container:
docker run -d --name budget-db -p 11433:1433 --network budget-app-network --network-alias mssql budget-db
When I want to enable the window container by using:
docker run -d --name budget-app -p 888:80 --network budget-app-network budget-app
I got an error says:
docker: Error response from daemon: network budget-app-network not found.
I can't find how to connect the web api to the database. How can I make to communication? I believe it would work if I would have an two linux or two windows containers and not mixed them.
Upvotes: 2
Views: 2229
Reputation: 5557
When you are running Windows and Linux container on a windows host, you have two docker engines running. One engine is running natively on windows and is running the windows containers, and one inside a virtual machine (Hyerp-V) running the linux continuers. This is discussed in the following thread on github
Because they are running on separate hosts, you need to manage the network in the same manner.
The easiest approach is to allow the containers to communicate trough the published ports, tough the windows host (routing the traffic trough the public IP of the host).
Also, you can use docker-compose as described in this post and allow docker-compose to create the network bridge between the VM containers and the windows contaierns.
Finally you have option to create a swarm by installing a linux and windows VMs (Hyper-V) and create a mixed-OS swarm. This is the most complicated option and the drawback is that you will have additional overhead from the additional windows machine running in hyper-v. The details are described in Microsfot's documentation
Upvotes: 2