虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论 取消回复
已有 14398 条评论
  1. jjfqnibakwop
    jjfqnibakwop
    回复

    online cialis buying cialis in mexico viagra & cialis cost of cialis at walmart generic cialis without a doctor's prescription
    generic cialis at walmart levitra without a doctor prescription cialis 20 mg walmart price when does cialis go generic cialis over the counter
    buy cialis on line online pharmacy cialis cialis online order tadalafil without a doctor prescription cialis on sale in usa cheap cialis online
    dfijuhcroceo cialis from usa tadalafil cialis prices does generic cialis work best cialis dosage

  2. lzqqxsoiwxtk
    lzqqxsoiwxtk
    回复

    cialis cost at walmart non prescription cialis cialis in usa viamedic.com cialis for everyday use
    cialis 20mg price how much does cialis cost walmart cialis generic tadalafil tadalafil walmart
    brand cialis for sale generic cialis without a prescription is there a generic cialis 5 mg. cialis meds without a doctor's prescription viagra without a doctor prescription
    vsmnwzkgwnux does cialis require a prescription cialis online no prescription where can i buy cialis generic cialis without a prescription cialis online without a prescription

  3. JimDes
    JimDes
    回复

    inderal 20 mg tablet clomid tablets where to get motilium can you buy neurontin over the counter bactrim ds cost avana india buy cytotec online with paypal advair.com

  4. KimDes
    KimDes
    回复

    lipitor 40 mg tablet price

  5. SueDes
    SueDes
    回复

    toradol gel paxil ssri over the counter amoxicillin without prescription ivermectin 3mg tab generic cialis capsules amoxil pill how to get cipro without a prescription generic tetracycline 500mg cost of ivermectin pill nolvadex online pharmacy

  6. tmfkmjuww
    tmfkmjuww
    回复

    Спасидо, +
    _________________
    I игровые автоматы с выводом денег

  7. wxikrzjhaeyc
    wxikrzjhaeyc
    回复

    online pharmacy cialis tadalafil online how to get cialis without a prescription real cialis cialis online without prescription
    is there generic cialis ceilas for sale cialis online without a prescription tadalafil 20mg cost of cialis in usa
    buy cialis from usa 5 mg. cialis how to get cialis without doctor cialis reviews tadalafil generic cost of cialis
    snlfvubkbzlw tadalafil buy cialis cialis from usa www cialis com lowest cialis prices

  8. TraceyTrift
    TraceyTrift
    回复

    Real Sex Model Meet Rich Daddy!
    For sexual pleasures in real life!
    Paid!
    Freebies fuck!
    https://cutt.us/real-model

  9. KimDes
    KimDes
    回复

    cost of advair generic

  10. Brianrenly
    Brianrenly
    回复

    navigate to these guys website link I thought about this

  11. Brianrenly
    Brianrenly
    回复

    click here to read he said get more information

  12. Brianrenly
    Brianrenly
    回复

    my website see this here read this post here

  13. Brianrenly
    Brianrenly
    回复

    Get More Info look at here Clicking Here

  14. JoeDes
    JoeDes
    回复

    advair online pharmacy medicine vermox hydroxychloroquine-o-sulfate buy azithromycin usa cialis 100mg antabuse pill over the counter inderal 40 cost

  15. lcaphjymuhec
    lcaphjymuhec
    回复

    walmart prescription prices tyekicginaua walmart drug prices canada drugs online online canadian pharmacy canadian meds generic for cialis in canada
    cialis canada uttrroestvoa northwestpharmacy com walgreens drug store prescription medication prescription drugs from canada canadian drugstore online
    drug store tklltbcuculo generic cialis canada cialis of canada drugs canada ed medication canadian rx
    cialis without prescription wpieapzwtxzf www.northwestpharmacy.com drugs from canada how to buy cialis in canada canadian pharmacy with cialis prescription medication

  16. KiaDes
    KiaDes
    回复

    60 mg zoloft pill

  17. RandellIdete
    RandellIdete
    回复

    джей казино официальный сайтджей казино официальный

  18. Aveyaobete
    Aveyaobete
    回复

    viagra mail order good reviewshttp://viagrauyr.com/ - buy viagraviagra cheapviagra softtabshttp://viagrayqdd.com/ - cheap viagraviagra online

  19. JimDes
    JimDes
    回复

    lexapro xanax prazosin tablets brand name elimite cream for sale

  20. JoeDes
    JoeDes
    回复

    mexico cipro allopurinol no rx buy dapoxetine tablets online india

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