Docker安装Mysql(二)配置Nginx

1、已安装nginx、mysql

2、查看mysql网址

 docker inspect mysql

 

 3、修改nginx配置文件,增加stream块

stream {
    upstream mysql {
       server 172.17.0.4:3306;
    }
    #配置mysql连接端口
    server {
        listen 3360;
        proxy_connect_timeout 100s;
        proxy_timeout 1h;
        #proxy_pass 172.17.0.4:3306;
        proxy_pass mysql;
    }
}

 

 4、创建nginx容器,设置80、3360 端口映射

docker run -d -p 80:80 -p 3360:3360 --name nginx -v /software/nginx/html:/etc/nginx/html -v /software/nginx/conf:/etc/nginx  -v /software/nginx/conf/nginx.conf:/etc/nginx/nginx.conf  -v /software/nginx/logs:/etc/nginx/logs nginx

5、测试

posted @ 2019-12-30 19:25  桥头堡洗脚城  阅读(195)  评论(0编辑  收藏  举报