虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 16858 条评论
  1. mmmaxim
    mmmaxim
    回复

    Купить игры xbox store на различные тематики + https://vk.com/public195417980
    Можно поиграть в Недорогие игры XBOX и стать чемпионом в UFC 3 бои без правил + https://vk.com/public195417980

  2. MiaDes
    MiaDes
    回复

    atarax 25mg for sleep advair cost comparison can you buy viagra over the counter in canada sildalis cheap can you buy viagra over the counter in usa

  3. UgoDes
    UgoDes
    回复

    how to purchase viagra in uk advair drug coupon cytotec 400 mcg hydroxychloroquine antiviral

  4. EvaDes
    EvaDes
    回复

    plaquenil for osteoarthritis

  5. JudyDes
    JudyDes
    回复

    www.cephalexin500mg cap.com generic vardenafil canadian pharmacy finasteride over the counter antabuse uk pharmacy paxil 30mg sildenafil 20 mg over the counter advair diskus 250 50 cost of generic plaquenil augmentin mexico pharmacy buspirone pill

  6. fzbwdavtcmjo
    fzbwdavtcmjo
    回复

    cialis daily
    cialis without a doctor 20mg canada rx
    is there a generic for cialis northwestpharmacy ed medication

  7. NickDes
    NickDes
    回复

    atarax 25 mg buy dapoxetine online india paxil 25 mg fluoxetine 30 mg nexium generic brand cost cheapest on line valtrex without a prescription

  8. most trusted canadian online pharmacies

    canadian pharmacies that ship to us
    http://canadianonlinepharmacygene.com/
    top rated canadian pharmacies online

  9. LisaDes
    LisaDes
    回复

    citalopram 40 mg

  10. BigBronup
    BigBronup
    回复

    how to get lasix online lasix online

  11. axbysz
    axbysz
    回复

    Chicago violence: Girl, 5, stabbed to death in another bloody weekend
    cialis tadalafil

  12. mxoyyovvvcrp
    mxoyyovvvcrp
    回复

    wlcjugblomxj wi ccap simple case search
    www.maryland case search odyssey case search northampton county court case number search pa judiciary case search

  13. veetazuczwvd
    veetazuczwvd
    回复

    hkrsjkcwosql palm beach clerk of courts case search
    search use case maryland court cases records search case search com case search maryland judiciary

  14. wzjtwesosztk
    wzjtwesosztk
    回复

    cialis without a doctor's prescription in usa
    cialis .com cheap cialis canada
    cialis online no prescription buying cialis online cialis without a doctor's prescription in usa

  15. whxwemuttcpj
    whxwemuttcpj
    回复

    hybbubjayjdl md gov case search
    los angeles county case search superior court san diego case search va case number search illinois courts case search

  16. zyxrnsidjhwx
    zyxrnsidjhwx
    回复

    ngsaeutzkaqm el paso county case search
    traffic case search district of columbia court case search ohio case search wisconsin judiciary case search

  17. KimDes
    KimDes
    回复

    where to buy keflex

  18. dzdaghuzwxwv
    dzdaghuzwxwv
    回复

    wzqdeammrvsl nc judicial case search
    suffolk county case search smith county judicial case search georgia judiciary case search will county circuit clerk case search

  19. zdtahtlsaosd
    zdtahtlsaosd
    回复

    viagra pharmacy online usa pharmacy online us pharmacy cialis highest rated canadian pharmacies viagra canada online pharmacy
    northwestpharmacy the canada pharmacy northwestern pharmacy canada viagra canadian pharmacy viagra from canada pharmacy
    pharmacy viagra cialis on canadian pharmacy cvs pharmacy canadian pharmacy-viagra canadian pharmacy cialis for daily use

  20. lasifurexnup
    lasifurexnup
    回复

    buy lasix online from New Zealand buy lasix in USA

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