msphpsql icon indicating copy to clipboard operation
msphpsql copied to clipboard

May be docker image?

Open yuriyzinchenko opened this issue 9 years ago • 20 comments

Do you plan to create a docker image?

yuriyzinchenko avatar Oct 06 '16 13:10 yuriyzinchenko

@yuriyzinchenko are you looking for a Docker image with the PHP Driver for SQL Server and its pre-requisites installed?

meet-bhagdev avatar Oct 10 '16 15:10 meet-bhagdev

@meet-bhagdev Yes. Or may be it's exists already?

yuriyzinchenko avatar Oct 11 '16 13:10 yuriyzinchenko

@yuriyzinchenko @meet-bhagdev I created this Dockerfile. it might work.

The only problem I have is that is returning pdo_sqlsrv_db_handle_factory: Unknown exception caught. I'm using that Dockerfile with a silex application and Doctrine DBA. it looks like that I'm not the only one wit that problem #161

danielnv18 avatar Oct 15 '16 18:10 danielnv18

@danielnv18 based on your file, I created my own Dockerfile. I add few instructions to avoid pdo_sqlsrv_db_handle_factory: Unknown exception.

RUN apt-get install -y locales \ && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ && locale-gen It seems like with the encoding problem was the cause of connection failure The docker image is available on the https://hub.docker.com/ nitra/php:php-7mssql

Full text of Dockerfile:

FROM nitra/php:php7

RUN printf "\n" | pecl install apcu
RUN docker-php-ext-enable apcu

# install the PHP extensions we need
RUN apt-get update && apt-get install -y locales unixodbc libgss3 odbcinst devscripts debhelper dh-exec dh-autoreconf libreadline-dev libltdl-dev unixodbc-dev wget unzip \
    && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-install pdo opcache \
    && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen

# Compile odbc_config
RUN cd /usr/local/src/ && dget -ux http://http.debian.net/debian/pool/main/u/unixodbc/unixodbc_2.3.1-3.dsc \
    && cd unixodbc-2.3.1/ && apt-get update && dpkg-buildpackage -uc -d -us -B && cp ./exe/odbc_config /usr/local/bin/

## Microsoft ODBC Driver 13 for Linux
RUN cd /usr/local/src/ \
    && wget https://download.microsoft.com/download/2/E/5/2E58F097-805C-4AB8-9FC6-71288AB4409D/msodbcsql-13.0.0.0.tar.gz \
    && tar xf msodbcsql-13.0.0.0.tar.gz && cd msodbcsql-13.0.0.0/ \
    && ldd lib64/libmsodbcsql-13.0.so.0.0; echo "RET=$?" \
    && sed -i 's/$(uname -p)/"x86_64"/g' ./install.sh \
    && ./install.sh install --force --accept-license
#
RUN cd /tmp && wget https://github.com/Microsoft/msphpsql/releases/download/v4.0.5-Linux/Ubuntu15.zip \
    && unzip Ubuntu15.zip \
    && mv -v Ubuntu15/* /usr/local/lib/php/extensions/no-debug-non-zts-20151012/ \
    && rm /usr/local/lib/php/extensions/no-debug-non-zts-20151012/signature \
    && rm -rf /tmp/*

RUN echo "extension=php_sqlsrv_7_nts.so" >> /usr/local/etc/php/conf.d/sqlsvr.ini \
    && echo "extension=php_pdo_sqlsrv_7_nts.so" >> /usr/local/etc/php/conf.d/sqlsvr.ini \
    && locale-gen


CMD ["php-fpm", "-F"]

EXPOSE 9000

yuriyzinchenko avatar Oct 16 '16 12:10 yuriyzinchenko

Thanks @yuriyzinchenko. That did the trick for that particular error.

danielnv18 avatar Oct 16 '16 13:10 danielnv18

@danielnv18 @yuriyzinchenko super cool. I will try out your docker image and let you know how it goes. If everything looks good, I will start evangelizing it.

We will also add the following to our getting started instructions.

RUN apt-get install -y locales \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
&& locale-gen

meet-bhagdev avatar Oct 17 '16 02:10 meet-bhagdev

msodbcsql-13.0.0.0.tar.gz is not available anymore at the URL provided. Here is the current wget with correct URL

wget "https://meetsstorenew.blob.core.windows.net/contianerhd/Ubuntu%2013.0%20Tar/msodbcsql-13.0.0.0.tar.gz?st=2016-10-18T17%3A29%3A00Z&se=2022-10-19T17%3A29%3A00Z&sp=rl&sv=2015-04-05&sr=b&sig=cDwPfrouVeIQf0vi%2BnKt%2BzX8Z8caIYvRCmicDL5oknY%3D" -O msodbcsql-13.0.0.0.tar.gz

vanomak avatar Dec 06 '16 02:12 vanomak

@yuriyzinchenko @vanomak, @meet-bhagdev and I have created a Docker image with the latest PHP drivers. Check it out here mssql-docker/php-mssql. This is also available on DockerHub under lbosqmsft/php-mssql. Let us know what you think!

LuisBosquez avatar Jan 26 '17 04:01 LuisBosquez

Great! What about php 7.1? And may be use official php image as the base?

yuriyzinchenko avatar Jan 26 '17 12:01 yuriyzinchenko

Here you have another Docker image I have created that includes mssql driver. Hope it will be helpful for you francarmona/docker-ubuntu16-apache2-php7-mssql_client. DockerHub: francarmona/docker-ubuntu16-apache2-php7-mssql_client

francarmona avatar Jan 31 '17 11:01 francarmona

I make this one under centos 7 and php 7.1.1. It also include soap for Exchange Webservices and ldap for autentifications. This is also available on DockerHub under reynier3mil/centos-php-fpm-msphpsql.

sirio3mil avatar Feb 03 '17 21:02 sirio3mil

@sirio3mil @francarmona @yuriyzinchenko @vanomak @danielnv18: We are working on a Docker image for developers looking to use PHP Drivers for SQL Server in a Docker setup and publish it on DockerHub here: https://hub.docker.com/r/microsoft/. We would like to get your feedback on what we should name it. Can you take this survey and let us know what you think? https://www.surveymonkey.com/r/ZW3G6LV

meet-bhagdev avatar Mar 03 '17 02:03 meet-bhagdev

mssql-php +1

Edited: I also voted in the survey

danielnv18 avatar Mar 03 '17 02:03 danielnv18

mssql-php +1

francarmona avatar Mar 03 '17 07:03 francarmona

sqlsrv-php, cuz sqlsrv is the Microsoft driver's name, mssql is the name of the old and obsolete non Microsoft connector for PHP, not even included in PHP 7.

sirio3mil avatar Mar 03 '17 08:03 sirio3mil

@danielnv18 @francarmona @sirio3mil We uploaded a newer version of this image here: https://hub.docker.com/r/lbosqmsft/mssql-php-msphpsql/

Please let me know if there's any feedback

LuisBosquez avatar Mar 04 '17 01:03 LuisBosquez

@LuisBosquez I'd like to see the related Dockerfile but the link seems dead. The new repo for php dev env for SQLServer seems to be this one

Glideh avatar Oct 26 '17 11:10 Glideh

@LuisBosquez I'd really like to see that image coming from a Microsoft official account on docker hub instead of your personal account. In addition it would be even better if it extended an official PHP base image instead of a bare Ubuntu one.

eseyden avatar Oct 30 '17 17:10 eseyden

@Glideh @eseyden I can work with Luis on this. We can definitely get them published to the official Microsoft account

meet-bhagdev avatar Oct 30 '17 20:10 meet-bhagdev

@meet-bhagdev Thank you! It was a little disconcerting being linked out to a personal github and dockerhub page from official documentation. Based on the contents of @LuisBosquez 's Dockerfile I was able to get the drivers working on the php:7-fpm image I use for our Laravel apps. If anyone is interested here is the Dockerfile I ended up with. https://gist.github.com/eseyden/9467bca6102666c823e20e9536e7b764

Thanks again for all the great work on improving the sqlsrv driver experience on php and linux.

eseyden avatar Oct 31 '17 20:10 eseyden