Container unable to connect to SQL Server locally

At home, I have both a desktop and a laptop, both running an up-to-date Windows 10 Pro, both connected to my Linksys router. On both I have the Docker for Windows beta installed. The laptop has an instance of Microsoft SQL Server running ('select @@version yields "Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64) Jun 17 2011 00:54:03 Copyright © Microsoft Corporation Developer Edition (64-bit) on Windows NT 6.2 (Build 9200: ) (Hypervisor) ")

I can build a Docker container on the desktop that includes WinODBC and can successfully connect to the SQL Server running on the laptop, including returning results from a SQL query. ODBC is configured to connect to “DeighanSurface”, the Windows computer name of the laptop (a Microsoft Surface Pro 3). I am doing nothing special to open port 1433 for the container (but it’s open in the computer’s firewall).

However, if I build the same container from the same source code on the laptop (where SQL Server is installed and running), the container that I build there cannot connect to the SQL Server instance. Here is the output from trying to run a Perl test script (the same one that succeeds on the desktop) in a bash shell:

C:\SQLTest> docker run -it --rm sqltest
root@883ee8c80738:/home/user# perl
DBI connect(‘LocalServer’,‘easyiep’,…) failed: [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired (SQL-HYT00) [state was HYT00 now 08001]
[unixODBC][Microsoft][ODBC Driver 11 for SQL Server]TCP Provider: Error code 0x2AF9 (SQL-08001)
[unixODBC][Microsoft][ODBC Driver 11 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. (SQL-08001) at line 15.
Connection failed: at line 15.

Expected behavior

The docker container should connect to the SQL Server running on the same computer.

Actual behavior

The connection fails with the error message above.


  • the output of:
    • pinata diagnose -u on OSX
    • DockerDebugInfo.ps1 using Powershell on Windows
  • a reproducible case if this is a bug, Dockerfiles FTW
  • page URL if this is a docs issue or the name of a man page
  • host distribution and version ( OSX 10.10.x, OSX 10.11.x, Windows, etc )

In my PowerShell, DockerDebugInfo.ps1 just yields:

DockerDebugInfo.ps1: The term 'DockerDebugInfo.ps1’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • DockerDebugInfo.ps1
  •   + CategoryInfo          : ObjectNotFound: (DockerDebugInfo.ps1`:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

Steps to reproduce the behavior

You should provide a way to attach files to these bug reports. The setup is pretty simple, though. The file ODBC.ini contains:

Driver = ODBC Driver 11 for SQL Server
Server = DeighanSurface

The test script,, contains:

#!/usr/bin/env perl

use strict;
use warnings;
use Data::Dumper;

use DBI;
use DBD::ODBC;

my $user = ‘easyiep’;
my $pwd = ‘ifahwtrg’;


my $dbh = DBI->connect(“dbi:ODBC:LocalServer”, $user, $pwd)
|| die(“Connection failed: $!”);
my $lData = $dbh->selectall_arrayref(“select count(*) from PermissionTypes”);
my $count = $lData->[0]->[0];
print(“There are $count PermissionTypes - OK\n”);
} # MAIN()

The Docker file is this (NOTE: I’m getting the message "Sorry, new users can only include 2 links in a post. Not sure what that means, but this Dockerfile includes 2 URLs which I’m going to modify to get the post in the system):

FROM ubuntu:trusty

— Download URLs

ENV FIX_SCRIPT Microsoft–SQL-Server–ODBC-Driver-1.0-for-Linux-Fixed-Install-Scripts
ENV FIX_SCRIPT_URL htps://${FIX_SCRIPT}/archive/

RUN apt-get -qq update
&& apt-get -y install unzip make gcc libkrb5-3 libgssapi-krb5-2 expat
libexpat1-dev tidy libtidy-dev libxml2-dev libssl-dev
libgd2-xpm-dev curl vim
wget aptitude dos2unix

— Download ODBC install files & scripts

RUN cd /tmp && wget -O msodbcsql.tar.gz ${MS_ODBC_URL} && wget -O ${FIX_SCRIPT_URL}

— Unzip downloaded files

RUN cd /tmp && tar -xzf ./msodbcsql.tar.gz && unzip -o ./ && cp ./${FIX_SCRIPT}-master/* ./msodbcsql-11.0.2270.0

— Run install scripts

RUN cd /tmp/msodbcsql-11.0.2270.0 && yes YES | ./ --accept-warning --libdir=/usr/lib/x86_64-linux-gnu && ./ install --accept-license --force

RUN cpan App::cpanminus

RUN cpanm DBI
RUN cpanm DBD::SQLite
RUN cpanm Date::Calc
RUN cpanm Tie::IxHash
RUN cpanm IO::Stringy
RUN cpanm Image::Size
RUN cpanm Storable
RUN cpanm FreezeThaw
RUN cpanm Readonly
RUN cpanm PDF::Reuse

RUN cpanm Data::ICal Date::ICal JSON Perl::Critic HTML::TagFilter Number::Format Data::Buffer Math::Units Class::Loader File::Which
RUN cpanm Test::Script Probe::Perl Parse::Eyapp Carp::Assert Perl::Tidy Pod::Spell PPIx::Utilities PPIx::Regexp Email::Address MIME::Lite
RUN cpanm Math::Random File::Find::Rule Switch XML::Hash Test::Inline Number::Compare Math::BigInt

RUN cpanm Crypt::PasswdMD5 Crypt::DSA Crypt::CAST5_PP Crypt::Rijndael
RUN cpanm Net::LDAP Net::FTPSSL Net::SAML2 Authen::SASL IO::Socket::IP IO::Socket::INET6 Socket6 Captcha::reCAPTCHA
RUN cpanm Data::UUID Digest Digest::SHA1 Test::More XML::DOM Mail::Sender Statistics::Basic Statistics::Descriptive Statistics::Distributions Statistics::TTest

RUN cpanm GD GD::Graph GD::Text Authen::Captcha Authen::Radius XML::LibXML
RUN cpanm Alien::Tidyp HTML::Tidy Time::Date CAM::PDF Archive::Zip SOAP::Lite

RUN mkdir /home/user
WORKDIR /home/user

ADD odbc.ini /etc/odbc.ini
ADD /home/user

RUN dos2unix -k -q /etc/odbc.ini /home/user/

ENV PERL5LIB /var/www/easyiep/PerlLibs
USER root

— Set the locale

RUN locale-gen en_US.UTF-8

CMD /bin/bash

Same issue here , the same configuration works on the host , but i m not able to connect inside the container in bridget or default networks

Did either of you get to the bottom of this?

Did anyone get through this error?