Docker container connecting to a MSSQL database

六月ゝ 毕业季﹏ 提交于 2019-12-11 04:38:57

问题


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/



来源:https://stackoverflow.com/questions/46367316/docker-container-connecting-to-a-mssql-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!