虫言虫语 虫言虫语

Docker基础使用(二)

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

在配置镜像之后可以进行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

支付宝打赏

文章二维码

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

发表新评论
已有 1308 条评论
  1. SueDes
    SueDes
    回复

    propecia online cost of ventolin in usa metformin 100 mg tablets buy albuterol prednisone 20mg allopurinol 300 mg tablet buy clomid sildenafil 120 mg can you buy doxycycline over the counter australia metformin buy online australia

  2. UgoDes
    UgoDes
    回复

    stromectol for sale albuterol purchase without prescription buy tetracycline 500mg online sildenafil 100mg albuterol coupon levitra 20 mg synthroid generic allopurinol 300 mg tablet

  3. UgoDes
    UgoDes
    回复

    fluoxetine 20 mg tetracycline 500 mg coupon zithromax 250 mg tab albuterol 180mcg buy prednisolone tablets retin a 0.1 cream buy generic albuterol lexapro 5mg

  4. WimDes
    WimDes
    回复

    buy azithromycin 500mg uk

  5. Stevnisa
    Stevnisa
    回复

    Canadian Online Drugs http://cheapcialisir.com - Cialis Viagra In 3 Days п»їcialis Buy Generic Tamoxifen

  6. MarkDes
    MarkDes
    回复

    metformin online india buy albuterol uk allopurinol tablets for sale azithromycin 500mg ventolin generic price price levitra albuterol 021

  7. BooDes
    BooDes
    回复

    lisinopril medicine tetracycline 100 mg where can you buy albuterol lexapro 10 mg azithromycin 250 mg over the counter

  8. Lesswesty
    Lesswesty
    回复

    Cephalexin For Tooth Pain http://cialisjh.com - Buy Cialis Nexium Coupons For Seniors Cialis Generique Propecia 1mg

  9. LisaDes
    LisaDes
    回复

    metformin 3115 tablets

  10. Lesswesty
    Lesswesty
    回复

    Viagra Dosierung http://buycialisuss.com - Cialis Commander Cialis Prix Discount Buy Cialis Viagra Livraison 48h

  11. JasonDes
    JasonDes
    回复

    can i buy propecia online lexapro tabs 10 mg cheap propecia generic tetracycline 300 mg retin a cost buy motilium buy cheap ventolin online stromectol south africa buy prednisolone 5mg uk lisinopril 2.5 pill

  12. Dan Danco
    Dan Danco
    回复

    This is a bleeding compelling post. Report register my purlieus best cbd oil for depression

  13. Angemier
    Angemier
    回复

    viagra online https://oliviapharm.com - online viagra prescription buy female viagra online uk generic viagra places to buy viagra online

  14. Stevnisa
    Stevnisa
    回复

    Death By Amoxicillin http://apcialisle.com/# - Buy Cialis Amoxicillin Sodium Market Report Cialis Best Site To Buy Viagra Online

  15. Lesswesty
    Lesswesty
    回复

    Buying Online Cialis http://buyciallisonline.com/# - buy cialis online Citalopram Purchase With A Mastercard Cialis Viagra Oficial

  16. WimDes
    WimDes
    回复

    albuterol coupon

  17. DenDes
    DenDes
    回复

    propecia 5mg online where to buy motilium online stromectol without prescription metformin 1000 mg no prescription prednisone medication

  18. MaryDes
    MaryDes
    回复

    metformin 500 mg stromectol buy sildenafil tablets colchicine medication ventolin 2.5 mg buy albuterol levitra 20mg australia zithromax 500 can i buy propecia online synthroid 0.125 mg

  19. MatExcupe
    MatExcupe
    回复

    Lowest Price Propecia Hair http://cialibuy.com/# - where to buy cialis online safely Cialis Viagra Cual Mejor Buy Cialis Last Longer In The Bedroom

  20. IvyDes
    IvyDes
    回复

    fluoxetine 20 mg allopurinol 300 mg price glucophage clomid lexapro 10 mg buy cafergot pills lisinopril 10 mg cost where can i buy stromectol synthroid 1 mg where to buy metformin uk motilium otc best generic metformin sildenafil price canada zithromax capsules 500mg buy discount levitra levitra 20 mg can i buy propecia over the counter uk propecia online lisinopril 20 buy doxycycline online australia colchicine 0.6 mg

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