Docker:phpadmin作为Apache2的单独容器

时间:2019-03-21 15:54:34

标签: mysql docker phpmyadmin

我在系统上运行的Apache2,PHP和mysql有单独的容器。诸如Web内容和数据库之类的内容文件存储在主机系统上已安装的卷中。这里的想法是,我可以在需要时轻松地换出单个容器。

我想在此设置中添加一个phpmyadmin容器,但是我不确定如何链接到它。下面是到目前为止的撰写文件,底部是phpmyadmin部分。

在非Docker服务器上,我只是在Apache配置中为安装文件夹创建一个别名,但是如何在此设置中指向Apache?我可以在Apache容器之前初始化phpmyadmin容器,然后从Apache将卷装载到phpmyadmin容器中吗?从而使我能够访问要用作服务器的文件?

谢谢。

version: '3.2'
volumes:
  apache2Config:
    external: true
  webContent:
    external: true
  databases:
    external: true

networks:
  frontend:
  backend:
    ipam:
      driver: default
      config:
        - subnet: 172.19.0.0/16

services:
  php:
    build:
      context: './php7.1/'
      args:
        PHP_VERSION: ${PHP_VERSION}
    image: php7.1.26-fpm:1.0
    restart: always
    container_name: php
    networks:
      backend:
        ipv4_address: 172.19.1.2
    volumes:
      - webContent:/var/www
  web:
    build: ./apache2/
    image: apache2:1.0
    restart: always
    container_name: AOW_apache2Server
    depends_on:
      - php
      - mariadb
    networks:
      backend:
        ipv4_address: 172.19.1.1
      frontend:
    expose:
     - "80"
     - "81"
     - "443"
     - "8083"
    ports:
     - "80:80/tcp"
     - "81:81"
     - "443:443"
     - "8083:8083"
    volumes:
      - apache2Config:/mnt/apache2Conf
      - webContent:/var/www
  mariadb:
    build: ./mariaDB/
    image: mariadb_10.4.0
    container_name: mariaDB_10.4.0
    networks:
      backend:
        ipv4_address: 172.19.1.3
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=***
    volumes:
      - databases:/var/lib/mysql
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    restart: always
    depends_on:
      - web
      - mariadb
    expose:
      - 80
    networks:
      backend:
        ipv4_address: 172.19.1.4
      frontend:
    ports:
      - 8080:80
    links:
      - mariadb
    environment:
      PMA_ARBITRARY: 1
      PMA_HOST: mariadb_10.4.0
      PMA_PORT: 3306

0 个答案:

没有答案