5

I am working on setting up a Docker build that will allow me to connect to SQL Server from Linux. As far as I know that has almost nothing to do with this question, but it might, because I'm pretty confused!

I am basing my image off Debian, as Debian is small and light. I suspect that I am missing some locale stuff and that is what causes this, but I do not know.

Anyway, here's my command + error:

$ perl -MDBI -MData::Dumper -E'say Dumper(DBI->connect("dbi:ODBC:server=10.6.6.17;port=1433;database=Lynx;driver=ODBC Driver 11 for SQL Server;uid=sa;pwd=password")->selectall_arrayref("SELECT * FROM Setup"))'
terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid

To me that looks like a C++ error, which might have to do with the SQL Server ODBC driver; it might be C++.

I have tried:

  • export LC_ALL=C
  • export LC_ALL=C.UTF-8
  • export LC_ALL=en_US.UTF-8
  • export LC_ALL=en_US
  • export LC_ALL=POSIX
  • apt-get install locales
  • locale-gen

And have made zero progress. Any ideas?

Appendix: the following is my actual Dockerfile; it is surely incomplete and could use some love, but it might help you in reproducing this error (note that the connect string in my command will need to be tweaked to point at a real SQL Server eventually, though not to repro this problem.)

FROM perl:5.20.1

RUN wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.2.tar.gz && \
    tar xf unixODBC-2.3.2.tar.gz                                   && \
    cd /root/unixODBC-2.3.2                                        && \
    ./configure --disable-gui --disable-drivers --enable-stats=no --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE && \
    make                                                           && \
    make install                                                   && \
    echo "include /usr/local/lib" >> /etc/ld.so.conf               && \
    ldconfig

RUN ln -s /usr/local/lib/libodbc.so.2 /usr/lib/libodbc.so.1          && \
    ln -s /usr/local/lib/libodbccr.so.2 /usr/lib/libodbccr.so.1      && \
    ln -s /usr/local/lib/libodbcinst.so.2 /usr/lib/libodbcinst.so.1  && \
    ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /usr/lib/libssl.so.10                        && \
    ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/libcrypto.so.10

RUN wget http://download.microsoft.com/download/B/C/D/BCDD264C-7517-4B7D-8159-C99FC5535680/RedHat6/msodbcsql-11.0.2270.0.tar.gz && \
    tar xf msodbcsql-11.0.2270.0.tar.gz && \
    cd /root/msodbcsql-11.0.2270.0      && \
    bash install.sh install --force --accept-license

RUN wget https://cpan.metacpan.org/authors/id/M/MJ/MJEVANS/DBD-ODBC-1.50.tar.gz && \
    tar xf DBD-ODBC-1.50.tar.gz && \
    cd /root/DBD-ODBC-1.50      && \
    perl Makefile.PL -u         && \
    cpanm --installdeps .       && \
    make                        && \
    make test                   && \
    make install
Frew Schmidt
  • 348
  • 1
  • 3
  • 11

1 Answers1

15

I figured it out!

I needed to follow these steps:

export DEBIAN_FRONTEND=noninteractive
apt-get install locales
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
locale-gen

and then the rest worked!

Frew Schmidt
  • 348
  • 1
  • 3
  • 11
  • If you have searched the whole internet looking for a solution to this problem, then you have finally arrived at the right place. Thank you for sharing your solution! – Olshansky Jun 02 '17 at 18:22