虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 16470 条评论
  1. ACrorgo
    ACrorgo
    回复

    online viagra without subscription viagra pill buy viagra online viagra without subscription viagroforsale.com generic viagra

  2. ACrorgo
    ACrorgo
    回复

    cheap viagra viagra dosage recommendations sildenafil 20 mg tablet vs viagra female viagra cheap viagra generic viagra

  3. KimDes
    KimDes
    回复

    paxil cost

  4. SueDes
    SueDes
    回复

    cephalexin 125 mg baclofen 10mg tablets price plaquenil singapore prescription medicine lisinopril buy zithromax online cheap avana 200 robaxin online uk amoxil 250 tablet motilium medrol 50 mg

  5. JoeDes
    JoeDes
    回复

    robaxin 750 price south africa triamterene 25 mg capsule 1000 mg zithromax online avodart 0.5 mg price in india dapoxetine price in india toradol 30 diclofenac dr cheapest finasteride generic

  6. Brianrenly
    Brianrenly
    回复

    what do you think special info websites

  7. JamesCrink
    JamesCrink
    回复

    Hello. And Bye.

  8. Williamseall
    Williamseall
    回复

    breaking 100mg viagra half http://viagrazum.com/# - viagra prescription como usar a romГЈ como viagra viagra without a doctor prescription buy viagra over counter boots

  9. CarlDes
    CarlDes
    回复

    best generic wellbutrin where can i get amoxicillin pills buy albenza canada tetracycline 1mg malegra 50

  10. JaneDes
    JaneDes
    回复

    seroquel 20

  11. Aneeroicy
    Aneeroicy
    回复

    corona virus has cure are antiviral medications safe en linea farmacia comprar viagra generico comprarviagra.uno why infection treatment. why infection treatment do antiviral drugs work against viruses 2019 9274389 , can infection treatment abort pregnancy. antivirala drugs for influenza, what does antiviral medication do.
    Online farmacia la comprar cialis viagra what yeast infection treatment should i use, antiviral medication for cats. antiviral medication for flu in pregnancy, How blood plasma from recovered people antiviral drugs for flu in the philippines. Online farmacia barato viagra sin receta site antiviral treatment for flu, antiviral drugs for flu for toddlers. Prevention of Coronavirus Disease 2019, what are antiviral drugs for the flu cure virus combination kaletra online.

  12. Brianrenly
    Brianrenly
    回复

    sneak a peek at this web-site blog pop over here

  13. DenDes
    DenDes
    回复

    phenergan 50 mg tablets generic vermox avodart medicine online dapoxetine 120 mg where can i get arimidex in australia

  14. cwuhmgzkxtbs
    cwuhmgzkxtbs
    回复

    cialis free does generic cialis work purchasing cialis in the usa cialis. com viagra vs cialis vs levitra reviews
    cialis for sale on internet cost of cialis 5 mg. cialis buy tadalafil online viagra cialis
    generic cialis without a doctor prescription generic cialis without a doctor prescription buy cialis online.com coupon for cialis prescription brand cialis for sale viamedic.com
    hwtttpymcxrs cialis 5 mg tadalafil 40 mg best price cialis cialis for everyday use cialis 5mg

  15. JaneDes
    JaneDes
    回复

    dipyridamole brand name australia

  16. AshDes
    AshDes
    回复

    motilium cost australia where to get nolvadex online plaquenil 200mg buy prednisolone 5mg online uk prazosin tablets brand name prozac generic cost canada diflucan 110 mg viagra without presc

  17. IvyDes
    IvyDes
    回复

    fluoxetine tablets in india amoxicillin cost in mexico motilium drug lipitor.com buy anafranil buy furosemide online australia order cialis online usa dapoxetine drug in india seroquel xr weight gain avana singulair cost without insurance 20mg paxil pharmacy prices for wellbutrin advair drug prices clomid otc canada propranolol buy canada flagyl drug generic viagra us pharmacy online cipro 250 mg elimite price online

  18. JoeDes
    JoeDes
    回复

    estrace generic advair 500 mg dipyridamole brand name australia acyclovir price singapore buy prazosin online inderal 20 pharmacy viagra toradol pill 10mg

  19. ChrisTuh
    ChrisTuh
    回复

    гидра сайтпо запросу скачать гидру на русском для андроид вы найдете настоящий гидра сайт

  20. LisaDes
    LisaDes
    回复

    ivermectin 1

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