I have a .NET application running on a windows 10 computer using docker and postgres. When I run using the
"DockerTest": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "asset",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
Connection string = "Server=localhost;Port=5433;Database=xxx;Uid=yyy;Pwd=zzz;",
option in VS2019 I can connect to my postgres database without problems.
When I try to run the application using the
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/asset",
"publishAllPorts": true,
"useSSL": true
},
option, I am getting errors connecting. Here is my connection string.
"Database1": "Server=host.docker.internal;Port=5433;Database=xxx;Uid=yyy;Pwd=zzz;",
No matter what I try for a connection string I get CONNECTION WAS REFUSED or TIMEOUT errors.
Can anyone give me pointer as to what to try? I have gone over the message boards for two days and tries WINDOWS DEFENDER additions for com.docker.backend, I have tried different connection strings, I have tried many many other ways to solve this and have come up blank.
The end goal is to have docker run my REST API and have postgres installed on the same computer but not running in docker.
NEW EDIT: July 6 1:45 AM MST
inside the container I ran the following:
C:\app>ipconfig
Windows IP Configuration
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . : allworx.activeis.ca
Link-local IPv6 Address . . . . . : fe80::c06e:18b5:f9e0:48bb%4
IPv4 Address. . . . . . . . . . . : 172.30.81.112
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . : 172.30.80.1
C:\app>ping host.docker.internal
Pinging host.docker.internal [10.0.0.47] with 32 bytes of data:
Reply from 10.0.0.47: bytes=32 time<1ms TTL=127
NOTE : if I try to run my own app in the environment it actually works in with the 10.0.0.47 it works (even with host.docker.internal)... It is just from inside the container that it does not make the Postgres connection.
**PG_HBA.CONF FILE :**
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
host all all 172.17.0.1/16 md5
NEW EDIT: July 6 2:00 AM MST If I use the IP address of my other network IPs on my host they all work as long as I put them into the PG_HBA.CONF FILE (in the dockertest option)
Nothing seems to make the transition from container to host when I run with the DOCKER option. Even when I add the 10.0.0.47 to the file and run with HOST.DOCKER.INTERNAL (which translates to 10.0.0.47) it still does not work
**PG_HBA.CONF FILE :**
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
host all all 172.17.0.1/16 md5
host all all 10.0.0.47/16 md5
host all all 169.254.214.72/16 md5
C:\Users\Chris\source\repos\QuickTech.Com\QuickTechAPI>docker network ls
NETWORK ID NAME DRIVER SCOPE
661118d67505 Default Switch ics local
eae6a3536ef1 nat nat local
9d0b1f0209f6 none null local
I've seen a bridge or other network added in my hours of scouring the internet. Do I need to add a network to docker to make this transition?
NEW EDIT: July 6 11:00 AM MST
Host File in host computer
10.0.0.47 host.docker.internal
10.0.0.47 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
I cannot open the hosts file (c:\windows\system32\drivers\etc) in the container to see what it contains.