多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### docker-compose:lnmp+redis+mongo服务,php加载扩展,直接复制下方代码即可 ``` version : '3.3' services: # mysql容器 mysql: container_name: lnmp_mysql image: mysql:5.7 restart: always ports: - 33061:3306 volumes: # - ./mysql/my.cnf:/etc/mysql/my.cnf - ./mysql/data:/var/lib/mysql #挂载数据目录到本地 - ./mysql/log:/var/log/mysql command: --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 --max_allowed_packet=256M --default-authentication-plugin=mysql_native_password --sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" environment: TZ: Asia/Shanghai MYSQL_ROOT_PASSWORD: '123456' MYSQL_DATABASE: 'bjl_local_db' MYSQL_USER: 'bjl_local_db' MYSQL_PASSWORD: '123456' privileged: true #这里本人还配置了phpmyadmin容器,相当于连接mysql的客户端工具 phpmyadmin: image: phpmyadmin/phpmyadmin container_name: lnmp_phpmyadmin restart: always ports: - 8888:80 environment: PMA_ARBITRARY: 1 TZ: Asia/Shanghai UPLOAD_LIMIT: 500M MYSQL_USERNAME: root MYSQL_ROOT_PASSWORD: 123456 PMA_HOST: lnmp_mysql privileged: true # redis容器 redis: container_name: lnmp_redis image: redis:7.0 restart: always # image: daocloud.io/library/redis:6.0.5-alpine # image: redis:5.0 ports: - 5000:6379 volumes: # - ./redis/data:/data #挂载数据目录到本地 - ./redis/redis.conf:/etc/redis/redis.conf - ./redis/logs:/logs command: [ "redis-server","/etc/redis/redis.conf" ] # privileged:true【使用该参数,container内的root拥有真正的root权限。否则,container内的root只是外部的一个普通用户权限】 privileged: true # nginx容器 nginx: container_name: lnmp_nginx image: nginx ports: - 8080:80 - 4000:443 working_dir: /wwwroot volumes_from: - php #继承phpfpm挂载目录 volumes: - ./html:/usr/share/nginx/html - ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./nginx/conf.d:/etc/nginx/conf.d - ./nginx/logs:/var/log/nginx depends_on: - php links: - php:php restart: always logging: driver: 'json-file' options: max-size: '10g' privileged: true # mongoDb容器 mongo: hostname: lnmp_mongo container_name: lnmp_mongo image: mongo:4.4.6 restart: always command: mongod logging: driver: 'json-file' options: max-size: '10g' volumes: - ./mongo/config/mongod.conf:/etc/mongod.conf:rw - ./mongo/configdb:/data/configdb:rw - ./mongo/db:/data/db:rw ports: - "27000:27017" environment: TZ: Asia/Shanghai MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: 123456 privileged: true # php容器 php: container_name: lnmp_php build: context: ./php # dockerfile文件路径 dockerfile: Dockerfile # 指定dockerfile文件名称 ports: - 9000:9000 tmpfs: /var/temp #上传临时文件夹 # links: # - mysql # - redis # - mongo links: - mysql:mysql - redis:redis - mongo:mongo environment: TZ: Asia/Shanghai working_dir: /wwwroot volumes: - ./wwwroot:/wwwroot #程序运行目录 - ./php/logs:/usr/local/var/log restart: always logging: driver: 'json-file' options: max-size: '10g' privileged: true ```