虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论 取消回复
已有 36220 条评论
  1. CarlDes
    CarlDes
    回复

    buy plaquenil uk bupropion 50 mg acyclovir 800 mg tadalafil online price trustworthy online pharmacy

  2. SamDes
    SamDes
    回复

    where can i buy zovirax online where can i buy celebrex allopurinol 300 mg australia levitra 20mg price in india tetracycline order azithromycin online usa synthroid 112 mg

  3. GregoryNuh
    GregoryNuh
    回复

    generic viagra for ed buying prescription viagra from canada
    ed tablets http://genericvgrshop.com viagra without doctor script
    buy prescription viagra buy prescription viagra online without

  4. WayneSmups
    WayneSmups
    回复

    buy prescription viagra online without viagra Without a Doctor Prescription
    erectile dysfunction medication http://genericvgrshop.com meds without a doctor prescription
    meds online without doctor prescription prescription viagra online without doctor

  5. cialifS
    cialifS
    回复

    buy cialis philippines does cialis ever expire

  6. Josephorgam
    Josephorgam
    回复

    generic viagra viagra only 0.2$
    do i have ed http://genericvgrshop.com buy prescription viagra
    generic viagra for ed medications without a doctor's prescription

  7. JamesEsorn
    JamesEsorn
    回复

    viagra prescription viagra online without doctor
    natural pills for ed http://genericvgrshop.com generic viagra
    generic viagra viagra

  8. JamesEsorn
    JamesEsorn
    回复

    buy generic viagra here generic viagra without a doctor prescription
    ed vacuum pump http://genericvgrshop.com generic viagra without doctor's prescription
    buy generic viagra generic viagra for ed

  9. Josephorgam
    Josephorgam
    回复

    buy viagra very cheap buy generic viagra here
    ed tablets http://genericvgrshop.com medications without a doctor's prescription
    buy generic viagra prescription viagra without a doctor

  10. JoeDes
    JoeDes
    回复

    viagra 25mg for sale finasteride 1mg discount coupon where can i buy bactrim online cymbalta brand name coupon dapoxetine australia

  11. GregoryNuh
    GregoryNuh
    回复

    generic viagra without doctor's prescription buy cheap prescription viagra online
    best ed solution http://genericvgrshop.com buy medication without an rx
    buy viagra very cheap generic viagra for sale

  12. canada pharmacies online prescriptions

    canada pharmaceuticals online
    http://canadianfastpharmacy.com/
    canadian online pharmacies legitimate

  13. GregoryNuh
    GregoryNuh
    回复

    generic viagra buy viagra very cheap
    ed meds online without prescription or membership http://genericvgrshop.com medications without a doctor's prescription
    buy prescription viagra generic viagra without a doctor prescription

  14. overseas pharmacies

    canadian pharmacy online
    http://canadiannextpharmacy.com/
    mexican pharmacy

  15. WayneSmups
    WayneSmups
    回复

    viagra prescription viagra online without doctor
    ed for men http://genericvgrshop.com medications without a doctor's prescription
    generic viagra without a doctor prescription generic viagra

  16. Liozhk
    Liozhk
    回复

    levitra 20mg - supervardp.com ed remedies

  17. JoeDes
    JoeDes
    回复

    best rx pharmacy online .5mg propecia daily online pharmacy nz cialis synthroid 175 sildenafil drug acyclovir over the counter cream

  18. cialifS
    cialifS
    回复

    canada cialis online cialis gives me diarrhea

  19. GregoryNuh
    GregoryNuh
    回复

    viagra only 0.2$ buy generic viagra here
    ed doctors http://genericvgrshop.com buy viagra very cheap
    meds online without doctor prescription meds without a doctor prescription

  20. WayneSmups
    WayneSmups
    回复

    buy generic viagra here buy prescription viagra online without
    ed remedies that really work http://genericvgrshop.com viagra only 0.2$
    buy prescription viagra online without buy viagra very cheap

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