Unable to connect to SQL

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Can you share your docker inspect results? And the command you're trying connect and exact error ?
3 years ago
nopAccelerate.com wrote:
Can you share your docker inspect results? And the command you're trying connect and exact error ?


logs as below:
ForceFlush is enabled for this instance.
2020-06-08 12:49:41.17 Server      Total Log Writer threads: 1. This is an informational message; no user action is required.
2020-06-08 12:49:41.21 Server      clflushopt is selected for pmem flush operation.
2020-06-08 12:49:41.22 Server      Software Usage Metrics is disabled.
2020-06-08 12:49:41.26 spid9s      [1]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-06-08 12:49:41.27 spid9s      Starting up database 'master'.
2020-06-08 12:49:41.29 Server      CLR version v4.0.30319 loaded.
ForceFlush feature is enabled for log durability.
2020-06-08 12:49:41.97 Server      Common language runtime (CLR) functionality initialized.
2020-06-08 12:49:42.00 spid9s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2020-06-08 12:49:42.02 spid9s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2020-06-08 12:49:42.16 spid9s      SQL Trace ID 1 was started by login "sa".
2020-06-08 12:49:42.23 spid9s      Server name is 'e8c600292c75'. This is an informational message only. No user action is required.
2020-06-08 12:49:42.28 spid11s     [32767]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-06-08 12:49:42.29 spid26s     Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2020-06-08 12:49:42.30 spid9s      [4]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-06-08 12:49:42.31 spid11s     Starting up database 'mssqlsystemresource'.
2020-06-08 12:49:42.31 spid26s     Always On: The availability replica manager is waiting for the instance of SQL Server to allow client connections. This is an informational message only. No user action is required.
2020-06-08 12:49:42.34 spid9s      Starting up database 'msdb'.
2020-06-08 12:49:42.36 spid11s     The resource database build version is 15.00.4033. This is an informational message only. No user action is required.
2020-06-08 12:49:42.47 spid11s     [3]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-06-08 12:49:42.48 spid11s     Starting up database 'model'.
2020-06-08 12:49:43.04 spid11s     Clearing tempdb database.
2020-06-08 12:49:43.06 spid23s     A self-generated certificate was successfully loaded for encryption.
2020-06-08 12:49:43.09 spid23s     Server is listening on [ 0.0.0.0 <ipv4> 1433].
2020-06-08 12:49:43.11 spid23s     Dedicated administrator connection support was not started because it is disabled on this edition of SQL Server. If you want to use a dedicated administrator connection, restart SQL Server using the trace flag 7806. This is an informational message only. No user action is required.
2020-06-08 12:49:43.13 spid23s     Server is listening on [ ::1 <ipv6> 1431].
2020-06-08 12:49:43.14 spid23s     Server is listening on [ 127.0.0.1 <ipv4> 1431].
2020-06-08 12:49:43.14 spid23s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
2020-06-08 12:49:43.83 spid51      [5]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-06-08 12:49:43.84 spid51      Starting up database 'ecomm'.
2020-06-08 12:49:44.23 spid11s     [2]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-06-08 12:49:44.24 spid11s     Starting up database 'tempdb'.
2020-06-08 12:49:44.36 spid51      Parallel redo is started for database 'ecomm' with worker pool size [1].
2020-06-08 12:49:44.44 spid51      Parallel redo is shutdown for database 'ecomm' with worker pool size [1].
2020-06-08 12:49:44.86 spid26s     The Service Broker endpoint is in disabled or stopped state.
2020-06-08 12:49:44.89 spid26s     The Database Mirroring endpoint is in disabled or stopped state.
2020-06-08 12:49:44.97 spid26s     Service Broker manager has started.
2020-06-08 12:49:45.01 spid9s      Recovery is complete. This is an informational message only. No user action is required.
2020-06-08 12:54:53.91 spid63      Attempting to load library 'xplog70.dll' into memory. This is an informational message only. No user action is required.
2020-06-08 12:54:54.06 spid63      Using 'xplog70.dll' version '2019.150.4033' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required.


inspect results as follows:
{
        "Id": "e8c600292c752d5f4bc45105e1371bdb4e9a477f56c128698f159fd60760ecfc",
        "Created": "2020-06-04T10:02:01.189500837Z",
        "Path": "/opt/mssql/bin/permissions_check.sh",
        "Args": [
            "/opt/mssql/bin/sqlservr"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 1964,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2020-06-08T12:49:20.586539295Z",
            "FinishedAt": "2020-06-08T12:48:20.047326112Z"
        },
        "Image": "sha256:d60e9ac97708e7568c2ce3bd2a282ee66022540f1cb815cb282f27512a3c44fd",
        "ResolvConfPath": "/var/lib/docker/containers/e8c600292c752d5f4bc45105e1371bdb4e9a477f56c128698f159fd60760ecfc/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/e8c600292c752d5f4bc45105e1371bdb4e9a477f56c128698f159fd60760ecfc/hostname",
        "HostsPath": "/var/lib/docker/containers/e8c600292c752d5f4bc45105e1371bdb4e9a477f56c128698f159fd60760ecfc/hosts",
        "LogPath": "/var/lib/docker/containers/e8c600292c752d5f4bc45105e1371bdb4e9a477f56c128698f159fd60760ecfc/e8c600292c752d5f4bc45105e1371bdb4e9a477f56c128698f159fd60760ecfc-json.log",
        "Name": "/ecomm_mssql_server",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "ecom_default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Capabilities": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/3eafb168ea83e80f33788ec30b5d6482201261823b8b3805c48829dcb2fb5674-init/diff:/var/lib/docker/overlay2/99c6ecaf1350b170bc1821607e74e45fc43a1a3d4dbfd7b257757accc6455dbd/diff:/var/lib/docker/overlay2/8051dc8ff40b3a85e2fa9ba47a815d52d0882a356f0397289fb03c4376c08ed0/diff:/var/lib/docker/overlay2/32e76ac5f4648a44258317a86d0c424cd2499d6bba91874b99f4497cf5998713/diff:/var/lib/docker/overlay2/5c9c3cd4cb59e74b0c915deea3d2d3e7ecd2ffa8547af9d4bc0d39e621dcf653/diff:/var/lib/docker/overlay2/215d489af144e53dba43fe802d22e7025d415a3d3825177bdb83a0b736978926/diff:/var/lib/docker/overlay2/aad7e5025147c2f6bf6a6e91822cb96cf19a989dd08b6f5c68f118c02d2be9c8/diff:/var/lib/docker/overlay2/5b1ba37a0f065f52ad5bd3b8ae5a6b09ca417d1550636bf041543206b84efcdf/diff:/var/lib/docker/overlay2/6d88ebe6d179ec6346105aab2f9767cd25e4cd243bd294edd84f2a5199091f40/diff",
                "MergedDir": "/var/lib/docker/overlay2/3eafb168ea83e80f33788ec30b5d6482201261823b8b3805c48829dcb2fb5674/merged",
                "UpperDir": "/var/lib/docker/overlay2/3eafb168ea83e80f33788ec30b5d6482201261823b8b3805c48829dcb2fb5674/diff",
                "WorkDir": "/var/lib/docker/overlay2/3eafb168ea83e80f33788ec30b5d6482201261823b8b3805c48829dcb2fb5674/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "e8c600292c75",
            "Domainname": "",
            "User": "mssql",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "1433/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "SA_PASSWORD=pass@word1",
                "ACCEPT_EULA=Y",
                "MSSQL_PID=Express",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/opt/mssql/bin/sqlservr"
            ],
            "Image": "mcr.microsoft.com/mssql/server:2019-latest",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/opt/mssql/bin/permissions_check.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "3a411bf10aa7c0eaa2071cd94db35c53373e58b20c104e420158c953f5b63969",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "ecom",
                "com.docker.compose.project.config_files": "docker-compose.yml",
                "com.docker.compose.project.working_dir": "C:\\users\\santosh.singh\\documents\\ecom",
                "com.docker.compose.service": "ecomm_database",
                "com.docker.compose.version": "1.25.5",
                "com.microsoft.product": "Microsoft SQL Server",
                "com.microsoft.version": "15.0.4033.1",
                "vendor": "Microsoft"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "618ff78bf15c6dbd07d81e7e250febdee30c6c2b2147c47b87b7c8a7550bfcca",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "1433/tcp": null
            },
            "SandboxKey": "/var/run/docker/netns/618ff78bf15c",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "ecom_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "ecomm_database",
                        "e8c600292c75"
                    ],
                    "NetworkID": "ff98ebaa95a12663a9e76b0b319652a2a3aa81eab10e175383a3c1e41c32fafa",
                    "EndpointID": "87614598b33b06d1cacb1e9f52fedb64a90b8ff33f921125949253fb4a355188",
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:12:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
3 years ago
what command you're trying to connect? What error do you get when you try to connect using sqlcmd.

And what happens when you try to connect using host as 172.18.0.2:1433?
3 years ago
nopAccelerate.com wrote:
what command you're trying to connect? What error do you get when you try to connect using sqlcmd.

And what happens when you try to connect using host as 172.18.0.2:1433?


3 years ago
santoshkmrsingh wrote:
what command you're trying to connect? What error do you get when you try to connect using sqlcmd.

And what happens when you try to connect using host as 172.18.0.2:1433?

3 years ago
May be you should also try with <ip-address>,<portnumber>

And can you share your docker-compose
3 years ago
nopAccelerate.com wrote:
May be you should also try with <ip-address>,<portnumber>

And can you share your docker-compose


Had tried that too didnt work. Below is the docker compose.


version: "3.4"
services:
    ecomm_web:
        build: .
        container_name: ecomm
        ports:
            - "80:80"
        depends_on:
            - ecomm_database
    ecomm_database:
        image: "mcr.microsoft.com/mssql/server:2019-latest"
        container_name: ecomm_mssql_server
        environment:
            SA_PASSWORD: "pass@word1"
            ACCEPT_EULA: "Y"
            MSSQL_PID: "Express"

volumes:
  ecomm_data:      
3 years ago
For sql being accessible outside docker you need to bind the port in the same way you've done for web app.
3 years ago
nopAccelerate.com wrote:
For sql being accessible outside docker you need to bind the port in the same way you've done for web app.


Thanks the issue resolved by updating the port mapping in the docker-compose.yml file

The port mapping was not updating when i was resuming the containers with a simple docker-compose start so i had to put the environment down and deploy the containers again using
docker-compose down
docker-compose up

the port mapping clearly shows local host mapping to the container and am able to connect with the management studio as well. Thanks for pointing me in the right direction you are a life saver was dreading the idea of having to explore the database from sqlcmd :-)
3 years ago
santoshkmrsingh wrote:
For sql being accessible outside docker you need to bind the port in the same way you've done for web app.

Thanks the issue resolved by updating the port mapping in the docker-compose.yml file

The port mapping was not updating when i was resuming the containers with a simple docker-compose start so i had to put the environment down and deploy the containers again using
docker-compose down
docker-compose up

the port mapping clearly shows local host mapping to the container and am able to connect with the management studio as well. Thanks for pointing me in the right direction you are a life saver was dreading the idea of having to explore the database from sqlcmd :-)


Glad it helped. :)

Best Regards,

nopAccelerate Team
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.