虫言虫语 虫言虫语

Docker基础使用(二)

in Dockerread (52763) 文章转载请注明来源!

在配置镜像之后可以进行docker的基础使用如
使用docker run XXXXX 来运行某个容器

我选择的使用docker-compose,相对更加简单简洁。

首先指定版本号

#选择2号对应新版本的docker
version: '2'
#开始定义服务
services:
  mysql:
    #mysql服务创建
    #image可以在hub.docker.com查询到对应的image名,这里推荐指定版本来保证环境的一致性,不会因为镜像升级使得环境出现问题
    image: "mysql:5.7.19"
    environment:
      MYSQL_ROOT_PASSWORD: "ROOT" 
      MYSQL_DATABASE: "docker"
      MYSQL_USER: "wormw"
      MYSQL_PASSWORD: "wormw"
    volumes:
    #信息后进行储存位置的映射储存,使产生的数据得到储存,而不是存储在内存中,当容器结束后数据就消失
      - ./db:/var/lib/mysql
    
  php:
    #利用dockerfile创建php7-fpm,主要是由于php需要加载许多第三方插件,直接加载image可能无法满足需求
    build:
    #context填写的是dockerfile的路径
      context: ./conf/php7
      dockerfile: Dockerfile
    volumes:
    #与上面的情况类似,这里加载volumes是为了让容器可以运行容器外的php程序,所以将目录进行了关联
      - ./web:/mnt/web
  web:
    #创建nginx服务,同时依赖php服务
    image: nginx
    volumes:
    #将本地配置文件通过映射关联给容器,实现对容器的配置
      - ./conf/nginx/config:/etc/nginx/conf.d
    ports:
    #绑定宿主机的80端口
      - "80:80"
    depends_on:
    #依赖php服务,实现容器间互相访问
      - php
    volumes_from:
    #访问php的本地卷
      - php
    networks: 
    #加入建立的网络中,实现容器间的互访
      - shared_net
    
  redis:
    image: redis:3.2.10
    ports:
      - "6379:6379"



  networks:
    #创建刚才引用的网络,将需要进行互联的容器加入同一网络中
    shared_net:
        external: true
    
jrotty WeChat Pay

微信打赏

jrotty Alipay

支付宝打赏

文章二维码

扫描二维码,在手机上阅读!

发表新评论
已有 10564 条评论
  1. Lesswesty
    Lesswesty
    回复

    Cephalexin Dosages And Use cialis Promethazine In Canada Propecia Analisis Viagra Acheter France

  2. Stepcrics
    Stepcrics
    回复

    Amoxicillin Liver Damage Reversible Last Longer In Bed Tonight generic viagra Purchasing Legally Amoxicilina Antibiotic Low Price Medication

  3. Stepcrics
    Stepcrics
    回复

    Dapoxetina Menarini Levitra 10 Mg Orosolubile Prezzo Farmacia Il Cialis Fa Male cialis 20mg for sale Generic Celias Tarif Cialis France

  4. Lesswesty
    Lesswesty
    回复

    Viagra 30 Anni cialis 5 mg Healthyman Viagra Viagra Con Drogas Amoxicillin 350mg Tid For 7 Days

  5. Stepcrics
    Stepcrics
    回复

    Kamagra China Priligy Precio 2011 C20 Without Prescription Viagra Deutsche Apotheke

  6. Lesswesty
    Lesswesty
    回复

    Provera Want To Buy cialis Buy Now Amoxicilina No Script Needed Dapoxetina Sp

  7. Stepcrics
    Stepcrics
    回复

    Dovobet Without Prescription cialis without prescription Keflex Cat Bladder Infection Viagra In Osterreich

  8. Lesswesty
    Lesswesty
    回复

    Amoxicillin 500mg Online Orders Buy 5 Mg Tadalafil Online Propecia Germany ??? viagra Isotretinoin price

  9. Stepcrics
    Stepcrics
    回复

    Rx Purple Pharmacy Mexico Price List cialis 5mg Viagra Sin Prescripcion Por Venta Cialis En Algerie Baclofene Medecin

  10. online pharmacy canada

    top rated online canadian pharmacies
    http://canadianpharmaciesoffer.com/
    online pharmacies canada

  11. online pharmacy with no prescription

    online pharmacy canada
    http://canadianhealthypharmacyrx.com/
    prescription drugs online without

  12. canadian pharmary without prescription

    online pharmacies
    http://canadianonlinepharmacycl.com/
    no prescription pharmacy canada

  13. canadian pharmacy

    canadian pharmacy online
    http://canadianonlinepharmacyhd.com/
    canada drugs no prescription needed

  14. canadian pharmacies

    canadian online pharmacies
    http://canadianonlinepharmacyoffer.com/
    canadian pharmacies that ship to us

  15. rx online no prior prescription

    canadian online pharmacy
    http://canadianonlinepharmacysl.com/
    online pharmacy

  16. canadian pharmacies online

    pharmacy without dr prescriptions
    http://canadianonlinepharmacywest.com/
    canadian pharmacy

  17. online pharmacy no prescription

    mexican pharmacies shipping to usa
    http://canadianpharmacieslink.com/
    online pharmacies

  18. prescription drugs online without

    best canadian mail order pharmacies
    http://canadianpharmaciesoffer.com/
    best online pharmacies in canada

  19. canadian online pharmacies

    safe online pharmacies in canada
    http://canadianpharmaciesprofmeds.com/
    canadian pharmacy

  20. online pharmacies canada

    online pharmacy
    http://canadianpharmaciesrxbest.com/
    canadian pharmacies

博客已萌萌哒运行
© 2020 由 Typecho 强力驱动.Theme by Yodu
前篇 后篇
雷姆
拉姆