虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 26621 条评论
  1. ThomasFrets
    ThomasFrets
    回复

    erection pills viagra online https://canadarx24.com/
    buy ed drugs

  2. JasonDes
    JasonDes
    回复

    clomid europe where to buy sildenafil 100mg amoxicillin 500mg capsules price can you buy viagra in europe cialis generic best price canada amoxicillin for sale online chloroquine phosphate 500 mg chloroquine otc usa azithromycin 250 mg pill finasteride online

  3. cheap viagra in kenya

    order viagra pfizer
    viagra vs avigra
    buy viagra hong kong prescription roani Cloup

  4. SamDes
    SamDes
    回复

    chloroquine diphosphate clomid prices how much is cialis canada chloroquine online propecia price uk how much is retin a cream prescription

  5. AlanDes
    AlanDes
    回复

    levitra pills in south africa viagra tablets 100mg viagra 800 mg best price zithromax 250mg viagra for cheap tretinoin cream online australia retin a online mexico clomid 100 mg vardenafil 20mg tablets chloroquine us

  6. ThomasFrets
    ThomasFrets
    回复

    prescription meds without the prescriptions https://canadarx24.com/
    viagra without a prescription

  7. JackDes
    JackDes
    回复

    azithromycin cost in india propecia cream hydroxychloroquine 200 mg cost prednisone 10mg generic cialis soft

  8. AnnaDes
    AnnaDes
    回复

    generic aralen finasteride price in india where to buy prednisolone 5mg how much is viagra in australia

  9. ThomasFrets
    ThomasFrets
    回复

    medications for https://canadarx24.com/
    male ed

  10. ciaSa
    ciaSa
    回复

    oxido nitrico cialis cialis 5mg tablet prijs cialis belgie

  11. ciaSa
    ciaSa
    回复

    cialis voucher phone number cialis 20mg for sale cde cialis

  12. ciaSa
    ciaSa
    回复

    cialis dosing options generic cialis 20 mg tadalafil cialis internetu

  13. viagra generic india

    buying tamoxifen
    viagra kidney
    www cialis com coupons roani Cloup

  14. ciaSa
    ciaSa
    回复

    cialis generico 50 mg cialis online without prescription does cialis cause muscle pain

  15. ThomasFrets
    ThomasFrets
    回复

    treatment of ed https://canadarx24.com/
    medicine erectile dysfunction

  16. ciaSa
    ciaSa
    回复

    does lisinopril interact with cialis generic cialis daily pricing cialis bph dose

  17. SamDes
    SamDes
    回复

    clomid price south africa hydroxychloroquine 4 mg

  18. JackDes
    JackDes
    回复

    brand levitra online tretinoin canada pharmacy tretinoin cream price india how much is tadalafil 20mg

  19. MiaDes
    MiaDes
    回复

    online pharmacy delivery usa doxycycline tab india retin a 025 gel where can i get cheap albuterol zitromax

  20. SueDes
    SueDes
    回复

    where can i buy amoxicillin uk genuine cialis price phenergan australia prescription viagra pills online south africa lipitor sales vardenafil discount cheap generic cialis online zithromax pill azithromycin tablets price in india vardenafil online india

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