Docker容器连接到MSSQL数据库 [英] Docker container connecting to a MSSQL database
问题描述
我有一张图片,我想用它来包含"我们的PHP应用程序与MSSQL数据库的连接.我从Dockerfile开始:
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
因此,我已经安装了正确的PHP驱动程序,并且代码已被复制.现在,我想从用户那里得到一些建议.我是否可以将网络添加为--network?我必须承认我对密闭容器"和桥接容器"的理解是有限的.像这样的命令:
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
似乎不起作用.如何从容器连接到192.168.3.55的MSSQL服务器?
don't seem to work. How do I connect to an MSSQL server at 192.168.3.55 from a container?
推荐答案
我通常使用 Docker完成此操作撰写及其链接选项.
I usually accomplish this using Docker Compose and its links option.
查看本教程 https://blog.codeship.com/orchestrate-containers-for-development-with-docker-compose/
这篇关于Docker容器连接到MSSQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!