2017-05-30 128 views
1

如何連接到我使用docker在Linux上創建的SQL Server?使用SQL Management Studio連接到Linux上的SQL Server(docker)

這裏是我的Dockerfile:

FROM microsoft/aspnetcore:1.1.2 
ARG source 
WORKDIR /var/www/aspnetcoreapp 
EXPOSE 80 
COPY ${source:-obj/Docker/publish} . 
ENTRYPOINT ["dotnet", "AspNetCoreWithSqlOnDocker.dll"] 

和我的搬運工,撰寫:

version: '2.1' 

services: 
    mssql: 
    image: "microsoft/mssql-server-linux" 
    environment: 
     SA_PASSWORD: "[email protected]" 
     ACCEPT_EULA: "Y" 
    ports: 
     - 1533:1533 
    networks: 
     - mynetwork 

    aspnetcorewithsqlondocker: 
    image: aspnetcorewithsqlondocker 
    ports: 
     - 5001:80 
    build: 
     context: ./AspNetCoreWithSqlOnDocker 
     dockerfile: Dockerfile 
    links: 
     - mssql 
    depends_on: 
     - mssql 
    networks: 
     - mynetwork 

networks: 
    mynetwork: 
    driver: bridge 

在這裏,你可以找到我的搬運工圖片:如果你想兩個容器連接內 enter image description here

回答

0

一個docker-compose,基本服務必須暴露端口。這需要調用暴露容器的應用程序看起來像這樣:

version: '2.1' 

services: 
    mssql: 
    expose: 
     - 1533 

    aspnetcorewithsqlondocker: 
    links: 
     - mssql 

您的連接的定義必須是:

HOST: mssql 
PORT: 1533 

順便說一句,你不必外面暴露的端口除非你想訪問容器外。

相關問題