移动位置

dockercompose部署lnmp_Docker

导入镜像

cat centos-7-x86_64.tar.gz | docker import - centos7:v1.0

dockercompose部署lnmp_Docker学习_02

查看镜像

dockercompose部署lnmp_Docker_03

创建安装LANM配置文件

dockercompose部署lnmp_Docker学习_04
安装检测目录工具

dockercompose部署lnmp_Docker学习_05

用法

dockercompose部署lnmp_Docker学习_06

version: '3'
services:
  nginx:
    hostname: nginx
    build:
      context: ./nginx
      dockerfile: Dockerfile
    ports:
      - 80:80
    networks:
      - lnmp
    volumes:
      - ./wwwroot:/usr/local/nginx/html

  php:
    hostname: php
    build:
      context: ./php
      dockerfile: Dockerfile
    ports:
      - 9000:9000
    networks: 
      - lnmp
    volumes:
      - ./wwwroot:/usr/local/nginx/html

  mysql:
    hostname: mysql
    image: mysql:5.6
    ports:
      - 3306:3306
    networks:
      - lnmp
    volumes:
      - ./mysql/conf:/etc/mysql/conf.d
      - ./mysql/data:/var/lib/mysql
    command: --character-set-server=utf8
    environment:
      MYSQL_ROOT_PASSWORD: dream0324
      MYSQL_DATABASE: bbs
      MYSQL_USER: bbs
      MYSQL_PASSWORD: dream0324

networks:
  lnmp:

已守护进程方式重启

systemctl daemon-reload && systemctl restart docker

dockercompose部署lnmp_Docker_07

配置容器

docker-compose -f LNMP_compose.yml up -d

dockercompose部署lnmp_Docker学习_08

访问测试

dockercompose部署lnmp_Docker学习_09