虫言虫语 虫言虫语

Docker基础使用(二)

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

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

    where to buy cheap viagra in uk azithromycin capsules levitra 75 mg buy ventolin pills online zithromax online canada

  2. ciaSa
    ciaSa
    回复

    cialis probleme cardiaque buy cialis toronto ko proizvodi cialis

  3. ThomasFrets
    ThomasFrets
    回复

    how to treat ed https://canadarx24.com/
    canadian drugstore online

  4. ciaSa
    ciaSa
    回复

    cialis 5 mg etkisi cialis online without prescription does cialis cause gout

  5. ciaSa
    ciaSa
    回复

    ultime notizie cialis buy cialis tadalafil0 with pay pal best price for cialis online

  6. ThomasFrets
    ThomasFrets
    回复

    carprofen without vet prescription https://canadarx24.com/
    otc ed pills

  7. JaneDes
    JaneDes
    回复

    where can i buy prednisone

  8. beFugsassurb
    beFugsassurb
    回复

    https://cialinic.com/ - how to get cheap tadalafil online

  9. Eylb07z
    Eylb07z
    回复

    http://doctorborat.com/ there natural viagra herb blue pill viagra what is dosage for tylenol 8 hr arthritis

  10. ciaSa
    ciaSa
    回复

    does cialis increase nitric oxide cialis without presciption in usa cialis preise niederlande

  11. SueDes
    SueDes
    回复

    discount generic propecia clomid tablet price india buy prednisone online no prescription best buy generic viagra buy levitra safely online purchase doxycycline online uk discount levitra prices prices for cialis levitra online rx cheapest prednisone no prescription

  12. ciaSa
    ciaSa
    回复

    cialis reactions can i buy cialis online cialis racconti

  13. Ihuckho
    Ihuckho
    回复

    viagra find a doctor near me viagra call your doctor

  14. Albertanind
    Albertanind
    回复

    buy real viagra no prescription
    cialis dosage 40 mg
    buy viagra online europe
    best place to buy cialis online reviews
    viagra sale dublin

  15. Klionorp
    Klionorp
    回复

    generic viagra cialis paypal viagra maintain erection after ejaculation dapoxetine and viagra review actually pay with paypal viagra viagra online fast shipping no prescription where can i buy viagra viagra canada pharmacy buy viagra using paypal viagra ireland online %viagra online buying viagra online online viagra sales viagra online without a prescription profesional viagra will viagra make you last longer

  16. NickDes
    NickDes
    回复

    can i buy lipitor online tadalafil 10 mg where can i buy finasteride

  17. EvaDes
    EvaDes
    回复

    buy generic tadalafil online cheap

  18. Yhvuxsc
    Yhvuxsc
    回复

    viagra gГ©nГ©rique livre sous 48h viagra sans ordonnance france cialis sans ordonnance

  19. JackDes
    JackDes
    回复

    stromectol covid 19 20 mg prednisone tablet vardenafil 40 mg plaquenil 50 mg discount viagra canadian pharmacy real viagra from canada plaquenil discount

  20. MaryDes
    MaryDes
    回复

    chloroquine buy 100mg generic sildenafil synthroid 75 mg price plaquenil 200mg tablets 100 plaquenil 10 mg buying lipitor online tadalafil generic canada buy cheap generic viagra online tretinoin 0025 albuterol 0.042

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