简体   繁体   中英

Unable to connect to SQL Server running in container inside Ubuntu VM on Azure

docker-compose.yml

version: "3"
services:
    coreapi:
        build:
            context: ./theapi
            dockerfile: Dockerfile
        ports:
            - "5000:5000"
    sqlserver:
        build:
            context: ./sqlserver
        ports:
            - "1433:1433"    
        environment: 
            - ACCEPT_EULA="Y"
            - SA_PASSWORD="Pwd12345!"
    angular:
        build:
            context: ./frontend
            dockerfile: Dockerfile
        ports:
            - "4300:4200"    

在此处输入图片说明

I read similar post on stackoverflow and add opened inbound port on my VM.

But to no avail:

在此处输入图片说明

Edit: 在此处输入图片说明

NSG - Inbound port rule -> Allow any "source port" to connect to your Sql server running in Docker by changing the value from 1433 to *.

It will resolve your issue. I replicated your steps and reproduced your issue. This fix will resolve it.

Reference I used to do your setup https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-ver15&pivots=cs1-bash

NOTE: There is a separate MS Sql server image in docker for Ubuntu. I believe you are using an image for linux.

My sql server which is running in docker inside ubuntu Az VM: 在此处输入图片说明

My Azure ubuntu VM config: 在此处输入图片说明

My NSG inbound port rule: 在此处输入图片说明

Connection from SSMS:

在此处输入图片说明

Connection details: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM