Connect to SQL Server database from a docker container

前端 未结 3 576
不知归路
不知归路 2021-02-01 06:49

I have docker for windows installed on my machine. There is a console application targeting .net core 1.0.0 that tries to access a SQL Server database running on a different VM.

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 07:26

    You can run a docker container with network settings set to host. Such a container will share the network stack with the docker host and from the container point of view, localhost (or 127.0.0.1) will refer to the docker host.

    docker run --net=host ... 
    

    Then you should get the SQL Server database from inside the docker container as you do from your host.

提交回复
热议问题