I need to install sqlsrv driver on my docker container. Currently my default connection using mysql, but i have added another connection using sqlsrv.
I’m using PHP 7.4 and the following is my dockerfile setup
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 \
&& 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/*
ENV ACCEPT_EULA=Y
# Microsoft SQL Server Prerequisites
RUN apt-get update \
&& 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 \
&& apt-get install -y --no-install-recommends \
locales \
apt-transport-https \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen \
&& apt-get update \
&& apt-get -y --no-install-recommends install \
unixodbc-dev \
msodbcsql17
RUN docker-php-ext-install mbstring pdo pdo_mysql \
&& pecl install sqlsrv pdo_sqlsrv xdebug \
&& docker-php-ext-enable sqlsrv pdo_sqlsrv xdebug
# 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 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"]
When i run docker-compose up, it gave me this listing of process
Attaching to mentor-app, webserver, db
mentor-app | [15-Feb-2022 03:02:26] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
mentor-app | [15-Feb-2022 03:02:26] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
mentor-app | [15-Feb-2022 03:02:26] NOTICE: fpm is running, pid 1
mentor-app | [15-Feb-2022 03:02:26] NOTICE: ready to handle connections
webserver | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
webserver | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
webserver | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
webserver | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
webserver | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
webserver | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
webserver | /docker-entrypoint.sh: Configuration complete; ready for start up
webserver | 2022/02/15 03:02:26 [notice] 1#1: using the "epoll" event method
webserver | 2022/02/15 03:02:26 [notice] 1#1: nginx/1.21.3
webserver | 2022/02/15 03:02:26 [notice] 1#1: built by gcc 10.3.1 20210424 (Alpine 10.3.1_git20210424)
webserver | 2022/02/15 03:02:26 [notice] 1#1: OS: Linux 3.10.0-1160.42.2.el7.x86_64
webserver | 2022/02/15 03:02:26 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
webserver | 2022/02/15 03:02:26 [notice] 1#1: start worker processes
webserver | 2022/02/15 03:02:26 [notice] 1#1: start worker process 23
webserver | 2022/02/15 03:02:26 [notice] 1#1: start worker process 24
webserver | 2022/02/15 03:02:26 [notice] 1#1: start worker process 25
webserver | 2022/02/15 03:02:26 [notice] 1#1: start worker process 26
db | 2022-02-15T03:02:26.547217Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db | 2022-02-15T03:02:26.549124Z 0 [Note] mysqld (mysqld 5.7.22-log) starting as process 1 ...
db | 2022-02-15T03:02:26.552232Z 0 [Note] InnoDB: PUNCH HOLE support available
db | 2022-02-15T03:02:26.552252Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db | 2022-02-15T03:02:26.552257Z 0 [Note] InnoDB: Uses event mutexes
db | 2022-02-15T03:02:26.552262Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
db | 2022-02-15T03:02:26.552268Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
db | 2022-02-15T03:02:26.552272Z 0 [Note] InnoDB: Using Linux native AIO
db | 2022-02-15T03:02:26.552538Z 0 [Note] InnoDB: Number of pools: 1
db | 2022-02-15T03:02:26.552669Z 0 [Note] InnoDB: Using CPU crc32 instructions
db | 2022-02-15T03:02:26.554530Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
db | 2022-02-15T03:02:26.561856Z 0 [Note] InnoDB: Completed initialization of buffer pool
db | 2022-02-15T03:02:26.564294Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db | 2022-02-15T03:02:26.575976Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
db | 2022-02-15T03:02:26.585728Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db | 2022-02-15T03:02:26.585791Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db | 2022-02-15T03:02:26.609106Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db | 2022-02-15T03:02:26.609785Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
db | 2022-02-15T03:02:26.609795Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
db | 2022-02-15T03:02:26.610753Z 0 [Note] InnoDB: Waiting for purge to start
db | 2022-02-15T03:02:26.660928Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 19770932
db | 2022-02-15T03:02:26.661366Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db | 2022-02-15T03:02:26.662759Z 0 [Note] Plugin 'FEDERATED' is disabled.
db | 2022-02-15T03:02:26.663757Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220215 3:02:26
db | 2022-02-15T03:02:26.666957Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
db | 2022-02-15T03:02:26.667248Z 0 [Warning] CA certificate ca.pem is self signed.
db | 2022-02-15T03:02:26.669271Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
db | 2022-02-15T03:02:26.669314Z 0 [Note] IPv6 is available.
db | 2022-02-15T03:02:26.669327Z 0 [Note] - '::' resolves to '::';
db | 2022-02-15T03:02:26.669342Z 0 [Note] Server socket created on IP: '::'.
db | 2022-02-15T03:02:26.679821Z 0 [Note] Event Scheduler: Loaded 0 events
db | 2022-02-15T03:02:26.680032Z 0 [Note] mysqld: ready for connections.
db | Version: '5.7.22-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
It seems the sqlsrv part does not execute, and the installation of nano and vim editor also not working.
Please help. Thank you