使用apache和mysql

时间:2017-11-17 15:07:16

标签: mysql apache docker production-environment

我在repo中收到了02个docker文件作为env config的一部分。 对于阿帕奇 和对于mysql

代码印在下面。

我想在我的Windows 7 64位系统中导入和设置相同的环境。我在我的机器上安装了DockerToolbox,但不知道如何导入这些配置。

欢迎提出意见,并提前致谢

1. FROM centos:7

RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
    yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm && \
    yum install -y yum-utils && \
    yum-config-manager --enable remi-php56 && \
    yum update -y && \
    yum install -y php httpd php-common php-cli php-pdo php-mysqlnd \
                php-gd php-xml php-ldap php-opcache php-soap php-zip && \
    yum clean all && \
    rm -rf /var/www && \
    mkdir /var/www && \
    groupadd -f www-data && \
    useradd --no-log-init --no-create-home --shell /usr/sbin/nologin -g www-data www-data && \
    mkdir /tmp/session && \
    chmod 0777 /tmp/session

COPY ["./docker/config/httpd/httpd.conf", "/etc/httpd/conf"]
COPY ["./docker/config/httpd/httpd-foreground", "/usr/bin/"]
COPY ["./docker/config/httpd/vhost.conf", "/etc/httpd/conf.d/marcopolo.conf"]

EXPOSE 80
CMD ["httpd-foreground"]

2. FROM mysql:5.6

EXPOSE 3306

1 个答案:

答案 0 :(得分:1)

我找到了docker-compose.yml

添加为:

version: '2'
services:

    httpd:
        build:
          context: ./
          dockerfile: ./docker/Dockerfile.httpd
        image: project-httpd
        container_name: my-httpd
        tty: true
        depends_on:
          - mysql
        environment:
            SYMFONY__DATABASE__HOST: "mysql"
            SYMFONY__DATABASE__PORT: "3306"
            SYMFONY__DATABASE__NAME: "mydb"
            SYMFONY__DATABASE__USER: "root"
            SYMFONY__DATABASE__PASSWORD: "root_pw"
            SYMFONY__APPLICATION__SECRET: "yoursec"
            SYMFONY__APPLICATION__DEBUG: "true"
            SYMFONY__LOG__FILENAME: "php://stdout"
            SYMFONY__DATASTORAGE__PATH: "/tmp"
            SYMFONY__DATASTORAGE__PATH_PUBLIC: "/tmp"
            REMOTE_USER: "testuse"
        volumes:
          - ./:/var/www:z
          - ./docker/config/httpd/php-d-ovveride.ini:/etc/php.d/zz-php-d-ovveride.ini
        ports:
          - 80:80
        networks:
          - default

    mysql:
        build:
          context: ./
          dockerfile: ./docker/Dockerfile.mysql
        image: my-mysql
        container_name: my-mysql
        entrypoint: docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
        environment:
          MYSQL_ROOT_PASSWORD: "root_pw"
          MYSQL_DATABASE: "mydb"
          MYSQL_USER: "db_user"
          MYSQL_PASSWORD: "db_user_pw"
        volumes:
          - ./:/var/www:z
          - mysql-volume:/var/lib/mysql:z
        networks:
          - default

volumes:
  mysql-volume:

networks:
  default:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 10.10.105.0/24
          gateway: 10.10.105.1

然后开火码头 - 组成,它起作用。

但在我看来Centos-7有点重,正在努力用Apline取代它