markdown Docker多容器和反向代理nginx

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Docker多容器和反向代理nginx相关的知识,希望对你有一定的参考价值。

version: '2'

services:
  nginx-proxy:
    container_name: nginx-proxy
    image: jwilder/nginx-proxy
    network_mode: "bridge"
    ports:
      - "80:80"

    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

  mysql:
    container_name: mysql_global
    image: mysql:5.6
    network_mode: "bridge"
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_USER=default
      - MYSQL_DATABASE=default
      - MYSQL_PASSWORD=default

  portainer:
    container_name: portainer-global
    image: portainer/portainer
    ports:
      - "8001:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
# Configuration
the file <docker-compose.yml> is principal file.
Into file is set custom network for all containers with you wuold using with reverse proxy.

The <docker-compose.yml> start with some container:
- mysql: for manfge all DBs of yours project (this is a solution for not use the TCP proxy)
- portainer: this is a container for mange docker (access url: http://localhost:9000)

You can edit "network_mode" with the network that reverese proxy using.

Remember every container of the your project will have to use with the network of the reverse proxy.

以上是关于markdown Docker多容器和反向代理nginx的主要内容,如果未能解决你的问题,请参考以下文章

markdown Docker Nginx反向代理+密码认证+ http

nginx 反向代理可以访问多个 docker 容器

对 docker 容器使用 nginx 反向代理

docker 安装 nginx 并配置反向代理

Nginx反向代理docker容器进行域名解析绑定的实现方法

apache2反向代理到docker容器403被禁止?