虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 14395 条评论
  1. usylrqoknjbw
    usylrqoknjbw
    回复

    viagra at canadian pharmacy onlinepharmacy.com cialis from canada pharmacy approved canadian online pharmacies canadian pharmacy online viagra
    online pharmacy cialis canadian viagra online pharmacy cialis online canadian pharmacy canadian pharmacies generic drugs online canadian pharmacy reviews
    online pharmacies canada best canadian pharmacies shipping to usa cialis and pharmacy canadian pharmacies without prescriptions www.canadian pharmacy

  2. MiaDes
    MiaDes
    回复

    buy malegra fxt celexa price in india levitra canada pharmacy online united states viagra buy augmentin 875

  3. gbpjmxomczxr
    gbpjmxomczxr
    回复

    cialis online pharmacy cialis canadian pharmacy's www.onlinepharmaciescanada.com best canadian online pharmacy reviews canadian discount pharmacies
    pharmaceuticals from canada canadian pharmacies viagra best canadian pharmacies shipping to usa canadian pharmacy cialis generic cialis-canadian pharmacy
    canadian pharmacy without a prescription canadian pharmacy cialis 20mg canadian pharmacy meds pharma from canada canada pharmacy cialis

  4. heloCrarl
    heloCrarl
    回复

    professional college application essay writers https://essaywriterdodo.com/ - online essay writers wanted auto essay writer cheapest essay writers essay writers needed

  5. NickDes
    NickDes
    回复

    sildenafil-citrate how can i get amoxicillin wellbutrin 300 mg coupon buy biaxin

  6. Lqcdmij
    Lqcdmij
    回复

    cialis 20mg prix pharmacie https://www.cialiswlmrt.com/# - buy cialis online cost cialis nhs

  7. Randydum
    Randydum
    回复

    адвокат по 290 УКуголовный юрист

  8. NickDes
    NickDes
    回复

    buy cialis cheap prices fast delivery buy cheap sildenafil online plaquenil 200 price of digoxin hydroxychloroquine sulfate oval pill chloroquine albendazole over the counter amitriptyline 25mg price in usa

  9. xuwhmngwvxjn
    xuwhmngwvxjn
    回复

    cialis canada online pharmacy buy cialis online canada pharmacy canadian pharmacies shipping to usa canadian pharmacy for viagra my canadian pharcharmy online
    viagra from a pharmacy in canada northwestpharmacy.com canadian pharmacy.com viagra online canada pharmacy canadian pharmacy cialis 20mg
    canadian pharcharmy online reviews online canadian pharcharmy internet pharmacy canadian viagra online pharmacy reviews canada pharmacies

  10. NickDes
    NickDes
    回复

    levitra pharmacy online where can i buy aralen lasix over the counter australia

  11. Josephsup
    Josephsup
    回复

    Meds information sheet. What side effects? cost generic prozac without dr prescription Actual information about pills. Get here.

  12. ikolabaxy
    ikolabaxy
    回复

    cialis for sale http://aazmencial.com/ - buy tadalafil 20mg price tadalafil cialis without prescription buy tadalafil online

  13. order ca clomid

    or take wakening too much cartoonist order usa clomid online Omwbra ewtkob cialis mg 5 generic cialis tadalafil

  14. PaulDes
    PaulDes
    回复

    164 avana no prescription lasix digoxin potassium on line viagra order medrol

  15. MiaDes
    MiaDes
    回复

    dapoxetine price india order sildenafil citrate online buy atarax buy silagra online in india viagra for sale usa

  16. EvaDes
    EvaDes
    回复

    furosemide 40 mg cost

  17. AnnaDes
    AnnaDes
    回复

    cost for cialis 20mg buy metformin from mexico zanaflex 4 mg without prescription plaquenil buy online chloroquine phosphate for sale uk trental 400 online in india baclofen 10mg tablets

  18. jsxnyjpvofel
    jsxnyjpvofel
    回复

    canadian pharmacy-viagra canadian pharmacies without prescription canada pharmacy for cialis viagra india pharmacy canadian pharmacy viagra
    us pharmacy cialis pharmacy viagra canada pharmacy for cialis generic cialis canada pharmacy online cialis from canada pharmacy
    canadian pharmacy viagra online approved canadian online pharmacies www.canadian pharmacy onlinepharmacy.com canadianpharmacymeds.com

  19. Lrepdjo
    Lrepdjo
    回复

    viagra without a doctors prescription viagra without a doctor prescription https://withoutdct.com/# viagra without a prescription order generic viagra from india

  20. iseyzlyihauy
    iseyzlyihauy
    回复

    best canadian online pharmacy reviews cialis coupon for pharmacy cialis coupon for pharmacy best canadian pharcharmy online internet pharmacy
    best online pharmacies canada pharmacy online online canadian pharmacy canadianpharmacymeds.com www.canadian pharmacy
    www.northwestpharmacy.com cheap viagra online canada pharmacy canadian pharmaceuticals online pharmacy viagra canadian pharmacy cialis generic

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