![](/img/trans.png)
[英]How to bind mysql port from host to docker container without port clash
[英]How to reference host port from docker container in MSSQL Server connection string?
編排:
bridge
)網絡上運行。 起初,我只是將連接字符串保留為.,1444
但意識到容器必須在自身外部查找才能獲取所需的主機localhost。
到目前為止,我已經嘗試過:
127.0.0.1:1444
host.docker.internal:1444
127.0.0.1,1444
host.docker.internal,1444
.,1444
我不斷收到此錯誤:
Connection id "0HLV8EI9HSV9D", Request id "0HLV8EI9HSV9D:00000009": An unhandled exception was thrown by the application.
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)```
最常見的方法是在 docker 運行命令中添加--network="host"
,然后在 docker 容器中添加 127.0.0.1 將指向您的 Z05B6053C41A2130AFD6FC3B158BDA 主機。
如果這不適合你, 這個問題包含了一堆 hacky 方法來實現同樣的事情。
如:
我相信該鏈接將幫助您找到最適合您的解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.