Skip to content

Instantly share code, notes, and snippets.

@danielnv18
Last active Jan 20, 2020
Embed
What would you like to do?
Docker with php 7.3 with unixodbc, Microsoft ODBC Driver 17 for Linux and pdo_sql
FROM php:7.3-fpm
MAINTAINER Daniel Noyola <daniel.noyola.dev@gmail.com>
# Install Dependencies
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 \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
# Add Microsoft repo for Microsoft ODBC Driver 17 for Linux
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y \
apt-transport-https \
msodbcsql17
# Enable the php extensions.
RUN pecl install pdo_sqlsrv-5.6.1 sqlsrv-5.6.1 \
&& docker-php-ext-enable pdo_sqlsrv sqlsrv
CMD ["php-fpm", "-F"]
EXPOSE 9000
@BlueM
Copy link

BlueM commented Nov 21, 2019

Lines 14 ff. do not work in this order: you first have to add the apt sources, then update apt before you can install msodbcsql17.

@chorsnell
Copy link

chorsnell commented Jan 20, 2020

As @BlueM mentioned

RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
    && curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list

# Add Microsoft repo for Microsoft ODBC Driver 17 for Linux
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y \
    apt-transport-https \
    msodbcsql17

@danielnv18
Copy link
Author

danielnv18 commented Jan 20, 2020

Updated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment