Docker 配置PHP开发环境


基础准备:

# 安装PHP74-FPM
## docker pull php:7.4.1-fpm

# 安装PHP5.6.40-FPM
## docker pull php:5.6.40-fpm

# 安装nginx
## docker pull nginx
## docker tag nginx:latest nginx:v1

# 安装redis
## docker pull redis
## docker tag redis:latest redis:v1

# 安装MYSQL
## docker pull mysql:5.7.28

# 安装swoole
## docker pull phpswoole/swoole:4.4.14-php7.3
## docker tag phpswoole/swoole:4.4.14-php7.3 swoole:v44

# 创建一个私有网络
## docker network create scarecrow_net

# 以上安装为接下来的docker-compose作为镜像基础



php-nginx  docker-compose.yml

version: '3'
services:
    nginx:
        image: nginx:v1
        container_name: np-nginx
        restart: always
        ports:
            - 80:80   
            - 443:443
        links:
            - php74
            - php56
        volumes:
            - F:\DockerCache\Nginx\conf.d:/etc/nginx/conf.d
            - F:\DockerCache\Nginx\nginx.conf:/etc/nginx/nginx.conf
            - F:\DockerCache\Nginx\logs:/web/logs
            - F:\DockerCache\Nginx\html:/web/html
        networks: 
            - scarecrow_net
    php74:
        image: php:7.4.1-fpm
        container_name: np-php74
        restart: always
        volumes:
            - F:\DockerCache\PHP74\etc:/usr/local/etc
            - F:\DockerCache\Nginx\html:/web/html
        networks: 
            - scarecrow_net
networks: 
    scarecrow_net:
        external: true



mysql5.7 and mysql5.6 dokcer-compose.yml

version: '3.8'
services:
    mysql57:
        image: mysql:5.7.28
        container_name: mysql57
        restart: always
        ports:
            - 3306:3306
        volumes:
            - F:\DockerCache\Mysql\mysql57\mysqld:/var/run/mysqld
            - F:\DockerCache\Mysql\mysql57\data:/var/lib/mysql
            - F:\DockerCache\Mysql\mysql57\log:/var/log/mysql
        environment:
            - MYSQL_ROOT_PASSWORD=123456
        networks: 
            - scarecrow_net
    mysql56:
        image: mysql:5.6
        container_name: mysql56
        restart: always
        ports: 
            - 3307:3306
        volumes:
            - F:\DockerCache\Mysql\mysql56\mysqld:/var/run/mysqld
            - F:\DockerCache\Mysql\mysql56\data:/var/lib/mysql
            - F:\DockerCache\Mysql\mysql56\log:/var/log/mysql
        environment:
            - MYSQL_ROOT_PASSWORD=123456
        networks: 
            - scarecrow_net
networks:
    scarecrow_net:
        external: true


redis   docker-compose.yml

version: '3'
services:
    redis:
        image: redis:v1
        container_name: redis
        restart: always
        ports:
            - 6379:6379
        volumes:
            - F:\DockerCache\Redis:/web
        command: redis-server /web/conf/redis.conf
        networks: 
            - scarecrow_net
networks:
    scarecrow_net:
        external: true


swoole docker-compose.yml

version: '3'
services:
    redis:
        image: swoole:v44
        container_name: swoole
        volumes:
        - F:\DockerCache\Nginx\html\scarecrow.im\server:/web
        command: php /web/index.php
        networks: 
            - scarecrow_net
        ports:
            - 9502:9502
networks:
    scarecrow_net:
        external: true


elasticsearch and elastichd docker-compose.yml

version: '3.8'
services:
    elasticsearch:
        image: elasticsearch:7.9.1
        container_name: elasticsearch
        restart: always
        ports:
            - 9200:9200
            - 9300:9300
        environment:
            - discovery.type=single-node
    elastichd:
        image: containerize/elastichd:latest
        container_name: elastichd
        restart: always
        ports: 
            - 9800:9800


阅读数:517
如有疑问请与我联系:点击与我联系