My system have 2 types of database connections. 1 is mysql and another 1 is sqlsrv. I already install pdo_sqlsrv on my webserver container. The pdo_sqlsrv displayed on phpinfo() when I checked.
But when I login using credential that using sqlsrv, I still got ODBC driver error.
Is it because of my php.ini file has no extension of sqlsrv?
I check the file in container location /usr/local/etc/php and have 2 files which are php.ini-production and php.ini-development. Both of the files does not have sqlsrv extension. And all of the extensions were commented.
;extension=bz2
;extension=curl
;extension=ffi
;extension=ftp
;extension=fileinfo
;extension=gd2
;extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=ldap
;extension=mbstring
;extension=exif ; Must be after mbstring as it depends on it
;extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
;extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop
Or am I referring to wrong php.ini files? There are no other php.ini for my docker container except for those 2 when I check using grep.
I also cannot modify the php.ini files because docker user have no permission.
Here is my dockerfile:
FROM php:7.4-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
curl \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++ libssl-dev apt-transport-https gnupg
# Install Dependencies
RUN ACCEPT_EULA=Y apt-get install -y \
unixodbc \
unixodbc-dev \
libgss3 \
odbcinst \
locales \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
RUN apt-get update
# 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/10/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update
RUN pecl install pdo_sqlsrv-5.8.0 sqlsrv-5.8.0 && \
docker-php-ext-enable \
sqlsrv \
pdo_sqlsrv && \
docker-php-ext-install \
intl \
pdo_mysql \
zip \
exif \
opcache \
pcntl
# Install extensions
#RUN docker-php-ext-install pdo_mysql zip exif pcntl
#RUN docker-php-ext-configure gd --with-freetype --with-jpeg
#RUN docker-php-ext-install gd
# Install Editor
RUN apt-get -y update
RUN apt-get -y install vim
RUN apt-get -y install nano
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
#RUN chown -R www-data:www-data /var/www
#RUN chmod -R 777 /var/www/storage
RUN chmod -R 755 /var/www/storage
#RUN chmod -R 755 /var/www/storage/logs
RUN chmod -R 755 /var/www/storage/logs/laravel.log
# Change current user to www
USER www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]