虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 1310 条评论
  1. Johnny Pulica
    Johnny Pulica
    回复

    This is a very compelling post. Report register my purlieus RoyalCBD

  2. EyeDes
    EyeDes
    回复

    buy allopurinol doxycycline 40 mg generic levitra 20 mg stromectol 3 mg price synthroid 25 mg daily where to buy generic levitra prednisone 10mg no prescription zithromax 600 mg generic albuterol can i buy clomid over the counter in south africa metformin with no prescription retin a 025 sildenafil 90 mg propecia cheapest india no prescription metformin 500 mg tablet buy online propecia prescription uk azithromycin 500mg over the counter 25mg prednisolone fluoxetine cost australia ventolin 90 mcg

  3. PaulDes
    PaulDes
    回复

    ventolin over the counter doxycycline for sale usa buy levitra cafergot no prescription fluoxetine 20 mg for sale

  4. MatExcupe
    MatExcupe
    回复

    Lasix Sweden http://buycialisuss.com - Buy Cialis Free Shipping Worldwide Provera 5mg France Price Shop Cialis Keflex Topical Application

  5. MatExcupe
    MatExcupe
    回复

    Mifepristone Online In South Africa http://buyciallisonline.com/# - Cialis Buy Prevacid 15 Mg Solutab Buy Cialis Levitra Giovani

  6. JasonDes
    JasonDes
    回复

    azithromycin 250 mg over the counter 25mg prednisolone buy ventolin online uk allopurinol 100 mg levitra malaysia generic metformin clomid pills buy online colchicine 0.6 mg price buy albuterol buy propecia

  7. Lesswesty
    Lesswesty
    回复

    Viagra Cialis O Levitra http://abcialisnews.com - cialis 5mg Amoxicillin Tablets Ingredients Cialis Can I Give My Dog Amoxicillin

  8. DenDes
    DenDes
    回复

    stromectol 3 mg price where can i buy metformin over the counter buy clomid online uk paypal compare prices of generic levitra buy motilium

  9. LisaDes
    LisaDes
    回复

    fluoxetine 20 mg coupon

  10. Lesswesty
    Lesswesty
    回复

    Online Female Viagra http://viacialisns.com/# - Buy Cialis Acheter Viagra Ligne France Buy Cialis Buy Deltasone Without Prescription

  11. MatExcupe
    MatExcupe
    回复

    Cialis Vendita Acquistare Cialis http://buycialisuss.com - online pharmacy Generika Cialis Buy Cialis Est

  12. toncazy
    toncazy
    回复

    With thanks, I enjoy it.. lisinopril hydrochlorothiazide

  13. Lesswesty
    Lesswesty
    回复

    Amoxicillin 500mg Dosage http://cheapcialisir.com - Cialis Propecia Daily Dosage Merck generic cialis canada Viagra Effetti

  14. stulse
    stulse
    回复

    You suggested this fantastically. purchasing cialis online.

  15. EyeDes
    EyeDes
    回复

    prednisone 5092 buy propecia 5mg zithromax 500 tablet fluoxetine 10 mg cost buy metformin 850 mg stromectol price uk albuterol 0.021 buy lisinopril where can i buy clomid online safely allopurinol over the counter cheapest generic propecia doxycycline 100mg cost of generic synthroid brand levitra 20mg generic lisinopril 10 mg generic ventolin price where can i buy metformin online allopurinol 100 mg motilium over the counter australia azithromycin 500

  16. Lesswesty
    Lesswesty
    回复

    Kamagra Vente Libre Montreal http://abcialisnews.com - Buy Cialis Amoxil Clavulonic Acid cialis online Pruflox

  17. Lesswesty
    Lesswesty
    回复

    Levitra Strength http://viacialisns.com/# - Cialis Official Canadian Pharmacy cialis 20mg for sale Cheap Cialis Order Online

  18. Clense
    Clense
    回复

    Whoa lots of valuable material! pharmacy online prescription

  19. Lesswesty
    Lesswesty
    回复

    93 3109 Pill Amoxicillin http://abuycialisb.com - Buy Cialis Levitra Ohne Rezept Online Kaufen cialis On Line Amoxicilina

  20. JimDes
    JimDes
    回复

    allopurinol cost uk prednisolone 5mg tablets metformin 500 mg pill lisinopril pill 5 mg albuterol inhaler price buy metformin online without prescription

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