Docker container connecting to a MSSQL database

2019-08-04 17:06发布

问题:

I have an image that I would like to use to "containerize" our PHP application connection to an MSSQL database. I start with the Dockerfile:

FROM nsidhaye/msphpsql

ENV ENVIRONMENT development

ENV APACHE_DOCUMENT_ROOT /var/www

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

COPY MyAgsourceAPI /var/www/
COPY MyAgsourceAPI/as_sys2 /var/as_sys2

So I have the proper PHP drivers in place and the code has been copied. Now I would like to get some advice from users. Do I "add a network" as --network? I must admit my understanding of a "closed container" and a "bridged container" is limited. So commands like:

docker run --detach --net bridge -p 80:80 rkevinburton/myagsourceapi

don't seem to work. How do I connect to an MSSQL server at 192.168.3.55 from a container?

回答1:

I usually accomplish this using Docker Compose and its links option.

Check this tutorial https://blog.codeship.com/orchestrate-containers-for-development-with-docker-compose/



标签: php docker dns