所以我在Docker容器中运行了一个Nginx,我在localhost上运行了一个mysql,我想从我的Nginx中连接到MySql.MySql在localhost上运行,而不是将端口暴露给外部世界,所以它绑定在localhost上,而不是绑定在机器的ip地址上.
有没有办法从这个docker容器中连接到这个MySql或localhost上的任何其他程序?
我想使用docker-compose在"主机"网络中生成3个服务.这是我的docker-compose.yml文件:
version: '2'
services:
mysql:
image: mysql
net: "host"
nginx:
image: nginx
net: "host"
app:
image: tomcat
net: "host"
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
$ docker-compose up
[31mERROR[0m: Validation failed in file '.\docker-compose.yml', reason(s):
Unsupported config option for services.app: 'net'
Unsupported config option for services.mysql: 'net'
Unsupported config option for services.nginx: 'net'
Run Code Online (Sandbox Code Playgroud)
我在windows上使用boot2docker.
Docker和Docker-compose版本:
$ docker -v
Docker version 1.10.2, build c3959b1
$ docker-compose -version
docker-compose version 1.6.0, build cdb920a
Run Code Online (Sandbox Code Playgroud)
如果我通过使用手动运行所有服务docker run --net = "host"工作正常.
在文档中,我读到了docker-compose支持net命令:
净
网络模式.使用与docker client …