Skip to content

Instantly share code, notes, and snippets.

@danielnv18
Last active January 20, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielnv18/7e1c680bfd1fc48e4c2cc5a180dff1b7 to your computer and use it in GitHub Desktop.
Save danielnv18/7e1c680bfd1fc48e4c2cc5a180dff1b7 to your computer and use it in GitHub Desktop.
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

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

Updated!

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