虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 26621 条评论
  1. MiaDes
    MiaDes
    回复

    buying viagra price of amoxicillin 500mg in south africa doxycycline mono cialis 5mg daily price buy cialis in nz

  2. LokuSkype
    LokuSkype
    回复

    canada drugs the peoples pharmacy canadian mail order pharmacy

  3. JaneDes
    JaneDes
    回复

    prednizone for sale

  4. MiaDes
    MiaDes
    回复

    levitra on line can i buy retin a over the counter where to get zithromax over the counter online cialis prescription levitra tab 20mg

  5. ThomasFrets
    ThomasFrets
    回复

    top ed drugs https://canadarx24.com/
    cialis without a doctor's prescription

  6. haroldrk18
    haroldrk18
    回复

    My new hot project|enjoy new website
    http://italian.porn.fetlifeblog.com/?amyaextreme homemade porn video hall of fame porn videos patty cake porn star fucking best free live porn for christians annette schwarz free porn tube

  7. SamDes
    SamDes
    回复

    rx tadalafil tablets cialis prescription coupon quineprox 400 lipitor 20 mg price in india zithromax pack synthroid 1.5 levitracanada.com quineprox 10mg

  8. JimDes
    JimDes
    回复

    prednisolone tablets uk best otc viagra phenergan 10mg

  9. FgnhAstew
    FgnhAstew
    回复

    online super viagra australia viagra boots viagra no prescription where can i buy viagra in sydney viagra for men and women for sale viagra pills viagra online mexico cheap viagra mastercard viagra at tesco online buy viagra in sydney viagra en uk viagra online, 24 hour delivery buy viagra best viagra alternative walmart pharmacy viagra

  10. JoeDes
    JoeDes
    回复

    levitra 40 mg ivermectin stromectol can you buy doxycycline over the counter in nz brand viagra without prescription cheapest propecia for sale retin a 0.01 gel zithromax pills 500mg

  11. JaneDes
    JaneDes
    回复

    synthroid 0.05 mg daily

  12. ThomasFrets
    ThomasFrets
    回复

    ed solutions https://canadarx24.com/
    how to overcome ed

  13. JoeDes
    JoeDes
    回复

    inhaler albuterol pharmacy home delivery sildenafil over the counter us prednisone 250 mg

  14. KimDes
    KimDes
    回复

    sildenafil mexico cheapest

  15. Odgskdh
    Odgskdh
    回复

    viagra sans ordonnance acheter viagra viagra sans ordonnance

  16. ThomasFrets
    ThomasFrets
    回复

    viagra without doctor prescription amazon https://canadarx24.com/
    drugs causing ed

  17. JackDes
    JackDes
    回复

    online pharmacy europe buy levitra 20mg online 2985 doxycycline aralen buy cialis otc canada zithromax otc sildenafil in canada

  18. JoeDes
    JoeDes
    回复

    synthroid rx female viagra tablets

  19. KimDes
    KimDes
    回复

    cialis no prescription canada

  20. JackDes
    JackDes
    回复

    tretinoin 0.025 cream coupon prednisolone tablets over the counter lyrica 75 price plaquenil 800 mg amoxicillin buy no prescription cheapest vardenafil generic india generic tadalafil in usa

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