• centos7 docker安装 和在docker中搭建lnmp环境


    https://www.cnblogs.com/yufeng218/p/8370670.html

    https://www.cnblogs.com/qgc1995/archive/2018/08/29/9553572.html

    lnmp环境搭建

    注:在此文件中配置所需要的容器  docker-compose.yml  ,并执行:docker-compose up -d

    文件中内容:

     1 version: "2"
     2 services:
     3   web:    #容器名称
     4     image: hub.haha.com/library/nginx:latest #镜像
     5     restart: always    
     6     volumes:        #映射  外部目录对应docker的目录
     7       - ./www:/var/www/html
     8       - ./nginx/conf:/etc/nginx
     9       - ./nginx/log:/var/log/nginx
    10     ports:    
    11       - 8888:80        #映射对应的端口号
    12     networks:        #整体应用的网络名称
    13       - my-network    
    14     depends_on:    #依赖的对象
    15       - php
    16   php:
    17     image: hub.haha.com/library/phpfpm:latest
    18     restart: always
    19     volumes:
    20       - ./www:/var/www/html
    21       - ./php/conf.d:/usr/local/etc/php/conf.d
    22     networks:
    23       - my-network
    24     depends_on:
    25       - mysql
    26   mysql:
    27     image: hub.haha.com/library/mysql:latest
    28     ports:
    29       - 7000:3306
    30     volumes:
    31       - ./mysql/data:/var/lib/mysql
    32       - ./mysql/log:/var/log/mysql
    33       - ./mysql/conf:/etc/mysql/mysql.conf.d
    34     restart: always
    35     environment:    #初始化新建数据库
    36       - MYSQL_ROOT_PASSWORD=root
    37       - MYSQL_DATABASE=wechat
    38     networks:
    39       - my-network
    40 networks:    #网络名称
    41   my-network:
    42     driver: bridge         #  指定的运行驱动                                 
    version: "2"
    services:
      web:
        image: hub.haha.com/library/nginx:latest
        restart: always
        volumes:
          - ./www:/var/www/html
          - ./nginx/conf:/etc/nginx
          - ./nginx/log:/var/log/nginx
          - ./nginx/ssl:/etc/nginx/ssl
        ports:
          - 443:80
        networks:
          - ky-network
        depends_on:
          - php
      php:
        image: hub.haha.com/library/phpfpm:latest
        restart: always
        volumes:
          - ./www:/var/www/html
        networks:
          - ky-network
      redis:
        image: hub.haha.com/library/redis:3.2.10
        volumes:
          - ./redis:/data
        ports:
          - 192.168.0.0:6379:6379
        networks:
          - ky-network
        restart: always
      es:
        image: hub.haha.com/library/elasticsearch:6.4.3
        restart: always
        ports:
          - 9200:9200
          - 9300:9300
        environment:
          - "discovery.type=single-node"
        networks:
          - ky-network
      esadmin:
        image: mobz/elasticsearch-head:5
        restart: always
        ports:
          - 9100:9100
        networks:
          - ky-network
    networks:
      ky-network:
        driver: bridge
    [root@wayhood ky-docker]# cat docker-compose.yml
    version: "2"
    services:
      web:
        image: hub.haha.com/library/nginx:latest
        restart: always
        volumes:
          - ./www:/var/www/html
          - ./nginx/conf:/etc/nginx
          - ./nginx/log:/var/log/nginx
          - ./nginx/ssl:/etc/nginx/ssl
        ports:
          - 443:80
        networks:
          - ky-network
        depends_on:
          - php
      php:
        image: hub.haha.com/library/phpfpm:latest
        restart: always
        volumes:
          - ./www:/var/www/html
        networks:
          - ky-network
      redis:
        image: hub.haha.com/library/redis:3.2.10
        volumes:
          - ./redis:/data
        ports:
          - 192.168.0.0:6379:6379
        networks:
          - ky-network
        restart: always
      es:
        image: hub.haha.com/library/elasticsearch:6.4.3
        restart: always
        ports:
          - 9200:9200
          - 9300:9300
        environment:
          - "discovery.type=single-node"
        networks:
          - ky-network
      esadmin:
        image: mobz/elasticsearch-head:5
        restart: always
        ports:
          - 9100:9100
        networks:
          - ky-network
    networks:
      ky-network:
        driver: bridge

    docker exec -it wechat_web_1 bash或docker-compose exec php bash  进入docker中查看原始php目录

    1、安装Docker,命令:yum install docker-ce   默认安装最新版本

    yum install docker-ce

    安装Docker,命令:yum install docker-ce-版本号,我选的是17.12.1.ce,如下

    复制代码
    [root@localhost ~]# yum install docker-ce-17.12.1.ce

    2、安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

    $ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

    3、启动并加入开机启动

    $ sudo systemctl start docker
    $ sudo systemctl enable docker

    4、验证安装是否成功(有client和service两部分表示docker安装启动都成功了)

    $ docker version
  • 相关阅读:
    noi.ac NOI挑战营模拟赛1-5
    TJOI2015 弦论
    CQOI2018 破解D-H协议
    NOI2013 矩阵游戏
    NOI2015 荷马史诗
    NOI2015 寿司晚宴
    SDOI2014 重建
    NOI1999 生日蛋糕
    NOI2015 程序自动分析
    ZJOI2008 泡泡堂
  • 原文地址:https://www.cnblogs.com/gaogaoxingxing/p/11672342.html
Copyright © 2020-2023  润新知