虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 25865 条评论
  1. bfjuycruiciors

    online payday loans for bad credit https://sapaydayiloans.com/ - easy payday loans online payday loans no credit check direct payday loans guaranteed payday loans

  2. EvaDes
    EvaDes
    回复

    plaquenil canada

  3. JaneDes
    JaneDes
    回复

    plaquenil 200 mg oral tablet

  4. kszbuukkxlpl
    kszbuukkxlpl
    回复

    canada pharmacy online viagra generic pharmacy india highest rated canadian pharmacies canadian pharmacy.com
    approved canadian online pharmacies canadian pharmacy with viagra canadian discount pharmacies canadian pharmacies without prescriptions
    northwestpharmacy.com canada rite aid pharmacies cialis-canadian pharmacy canada pharmacy viagra

  5. NickDes
    NickDes
    回复

    plaquenil generic name cost suhagra 100mg tablet price sildalis tablets tadalafil 10 mg canadian pharmacy tizanidine 4 can i buy dapoxetine over the counter generic prozac 20mg

  6. KimDes
    KimDes
    回复

    buy viagra super active

  7. MiaDes
    MiaDes
    回复

    cheap viagra online in usa buy sildenafil pills online cymbalta 60mg chloroquine 250mg tab anafranil 10 mg

  8. JoeDes
    JoeDes
    回复

    can you buy propranolol online how much is furosemide 20mg hydroxychloroquine prices

  9. byjhAstew
    byjhAstew
    回复

    professional paper writing services https://papersonlinesfy.com/ - write my paper apa format online paper writer best paper writing services pay for someone to write your paper

  10. JimDes
    JimDes
    回复

    buy tadacip anafranil prescription malegra fxt without prescription

  11. SueDes
    SueDes
    回复

    aralen purchase bactrim ds buy without rx 750 mg amoxicillin buy real sildenafil online with paypal from india biaxin ear infection buy cheap zanaflex canadian pharmacy viagra 100 mg amoxicillin 1 gram furosemide on line augmentin 1000 mg tablet

  12. JoeDes
    JoeDes
    回复

    strattera online purchase buy generic effexor purplepill com nexium metformin 500mg with out presciption

  13. gruketudqyje
    gruketudqyje
    回复

    the canada pharmacy legitimate online pharmacies india canadian pharmacies without a prescription canadian online pharmacy viagra cialis mexico pharmacy
    northwest canadian pharcharmy online canadian pharcharmy online reviews cialis online canadian pharmacy online pharmacies without prescription onlinepharmacy.com
    canadian viagra online pharmacy reviews canada pharmacies online prescriptions cialis on canadian pharmacy northwestpharmacy.com scam cialis canada online pharmacy

  14. RobertTom
    RobertTom
    回复

    Medicines information. What side effects can this medication cause? buy lisinopril Some what you want to know about medicament. Read information here.

  15. NickDes
    NickDes
    回复

    how to buy viagra pills topamax bipolar glucophage 500mg cheap plavix price in uk periactin over the counter uk amoxicillin 500mg capsule

  16. JaneDes
    JaneDes
    回复

    buy zyban online south africa

  17. MiaDes
    MiaDes
    回复

    viagra 100mg for sale celexa 30 mg where to buy lasix water pill ciprofloxacin uk best price for atenolol 25mg

  18. ggglgzixzxjz
    ggglgzixzxjz
    回复

    canadian pharmacy - cialis canadian pharmacies for viagra canadian pharmacy cialis 20mg generic pharmacy canada pharmacies online prescriptions
    canadian viagra online pharmacy reviews viagra canada pharmacy onlinepharmacy.com canadian pharmacy without prescription indian pharma
    canadian pharmacies generic drugs online best canadian pharmacies shipping to usa pharmacy viagra viagra online canadian pharmacy canadadrugpharmacy.com

  19. bfjuycruiciors

    online payday loans no credit check https://sapaydayiloans.com/ - payday loans online same day deposit quick payday loans payday loans online quick payday loans

  20. aqmjhhrmdtii
    aqmjhhrmdtii
    回复

    northwestpharmacy viagra online canadian pharmacy canadian pharmacy viagra canada pharmacy online viagra cialis- canadian pharmacy
    cialis canada pharmacy the canadian pharmacy pharma from canada online pharmacies canada generic pharmacy
    viagra from canadian pharmacy canada online pharmacies viagra online pharmacy cialis canadian pharmacy cialis and pharmacy

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