虫言虫语 虫言虫语

Docker基础使用(二)

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

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

    real viagra online finasteride 5mg coupon tadalafil 20 mg soft tabs synthroid cheapest prices online cialis paypal

  2. EvaDes
    EvaDes
    回复

    propecia canada online

  3. Afmqdnfc
    Afmqdnfc
    回复

    http://doctorborat.com/ purchase female viagra online viagra without doctor prescription how can petting a dog lower blood pressure apply to the real wrld

  4. IvyDes
    IvyDes
    回复

    female viagra drug canada buy plaquenil online uk tretinoin gel singapore generic levitra 40mg albuterol 0.021 aralen hcl lipitor pfizer can i buy viagra without a prescription sildenafil purchase canada generic cialis fast delivery propecia medicine levitra 10mg hydroxychloroquine sulfate tablets 200 mg retin a where to buy uk sildenafil for sale uk

  5. NickDes
    NickDes
    回复

    amoxicillin 500 prescription doxycycline 400 mg price retin a 0.25 cream buy female viagra online best price lexapro 20 mg clomid price

  6. JoeDes
    JoeDes
    回复

    chloroquine generic brand buy cheap lexapro

  7. SamDes
    SamDes
    回复

    cialis pills sale online viagra no prescription buy phenergan

  8. LisaDes
    LisaDes
    回复

    tretinoin cream .05

  9. JvcxPseub
    JvcxPseub
    回复

    viagra in canada genuine viagra australia viagra alternatives australia men on viagra videos viagra montreal coupon viagra prescription buy good cheap viagra pfizer viagra 100 super force viagra viagra super overnight viagra • cialis • viagra super force reviews cheap brand viagra in usa buy generic viagra online usa viagra how to buy without prescription

  10. SamDes
    SamDes
    回复

    retin a buy australia doxycycline 2985 chloroquine 300 mg generic daily cialis plaquenil buy online

  11. EvaDes
    EvaDes
    回复

    tretinoin 10mg capsule

  12. Payday Loans
    Payday Loans
    回复

    apply for loan online

  13. DustiMoine
    DustiMoine
    回复

    Hey.
    I love jerking off cocks! Licking ass and balls!
    I love to fuck in the ass and mouth!
    Fuck me please ...... https://cutt.us/hennia2020
    ]

  14. JaneDes
    JaneDes
    回复

    drug lexapro

  15. KiaDes
    KiaDes
    回复

    cheap cialis 5 mg

  16. cialis where to buy in mississauga

    viagra soft tabs erfahrungen
    viagra 100 mg
    100 mg viagra us pharmacy roani Cloup

  17. viagra tablets online

    sildenafil 100mg india
    generic viagra us
    where to buy nizoral shampoo hair loss roani Cloup

  18. NickDes
    NickDes
    回复

    buy discount levitra 90 mg prednisolone compare generic viagra prices prednisone 10mg online albuterol 2.5 mg prices

  19. Getting A Loan

    payday loans new orleans

  20. NickDes
    NickDes
    回复

    retin a 0.1 mexico prednisone 200 mg tablets albuterol from canada viagra online paypal aralen online

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