虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 1309 条评论
  1. KiaDes
    KiaDes
    回复

    price of levitra 10 mg

  2. JasonDes
    JasonDes
    回复

    cheap sildenafil albuterol cost metformin 500 mg cheap clomid canada metformin 850g synthroid 112 mg levitra 20 mg cheap levitra tablet price in india zithromax azithromycin fluoxetine 60 mg tablet

  3. LisaDes
    LisaDes
    回复

    prednisone 20mg

  4. JackDes
    JackDes
    回复

    buy motilium metformin 1000 mg tablet ventolin prescription coupon lexapro 10 mg albuterol tablets over the counter metformin buy online australia

  5. IvyDes
    IvyDes
    回复

    buy lisinopril levitra prescription canada metformin 1000mg how to get azithromycin in usa sildenafil 20 mg price buy doxycycline online uk buy propecia colchicine 6 mg tablet cafergot australia motilium australia prescription over the counter synthroid lisinopril 40 mg price buy ventolin over the counter zithromax z pack levitra generic where to buy prednisone lexapro 10 mg buy retin a without prescription albuterol discount coupon buy albuterol

  6. TeoDes
    TeoDes
    回复

    cheap viagra online

  7. JasonDes
    JasonDes
    回复

    stromectol 3 mg price lexapro 20 mg pill buy motilium levitra 20mg coupon propecia uk buy brand propecia online buy sildenafil online how to get synthroid albuterol cost generic zithromax 250mg

  8. boigoks
    boigoks
    回复

    canadian pharmacy drugs online http://onlinepharmacy.today - buy viagra online canadian pharmacy aarp approved canadian online pharmacies

  9. IvyDes
    IvyDes
    回复

    cheap ventolin generic usa colchicine 6 allopurinol generic prednisone 40 mg sildenafil cheap pills purchase stromectol online best over the counter retin a cream motilium 10 buy clomid best price cafergot lisinopril without prescription ventolin coupon generic propecia india buy cheap generic propecia buy prednisolone 5mg tabs buy azithromycin 500mg uk fluoxetine 20mg tablets uk medicine albuterol pills metformin generic lexapro 10 mg

  10. JoeDes
    JoeDes
    回复

    medication fluoxetine 20 mg ventolin cost usa buy lisinopril

  11. JackDes
    JackDes
    回复

    metformin 500 can you buy accutane online amoxicillin 750 strattera brand name atarax 25 mg price kamagra 100mg price in india valtrex 500 mg

  12. KimDes
    KimDes
    回复

    zoloft 100mg price in india

  13. KiaDes
    KiaDes
    回复

    accutane pills buy

  14. JackDes
    JackDes
    回复

    acyclovir 400 mg zoloft 10 mg buy generic strattera buy generic tadalafil in us tretinoin for sale uk lisinopril 10mg buy accutane 20mg best price metformin 1 000mg

  15. LarPrema
    LarPrema
    回复

    best 10 online canadian pharmacies http://canadianmail-orderpharmacy.com - canadian pharmacy phentermine online pharmacy canada drug pharmacy

  16. Lesswesty
    Lesswesty
    回复

    Lowest Cialis Prices http://viacialisns.com/# - Buy Cialis About Cephalexin Antibiotics Cialis Propecia Low Testosterone

  17. Stevnisa
    Stevnisa
    回复

    Malegra Dxt Canada http://abuycialisb.com - cialis without prescription Discount Online Asthma Inhalers Cialis Onlinepharnacy

  18. Lesswesty
    Lesswesty
    回复

    Vagiral http://viacialisns.com/# - Cialis Viagra Sans Ordonnance cialis Achat Cialis Pro

  19. TeoDes
    TeoDes
    回复

    cheap viagra canada

  20. MarkDes
    MarkDes
    回复

    amoxicillin online fast delivery zoloft 10 mg buy indocin online buy kamagra tablets buy diflucan acyclovir over the counter in canada cost of atarax 25mg clomid for men

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