虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 6864 条评论
  1. RafSeinaclecoca

    hemp oil for pain http://buycbdoilonline.us.com/ - hemp oil for pain cbd oil for sale cdb oils

  2. innodield
    innodield
    回复

    cbd online http://cbdoilrx.us.com/ - cbd pure buy cbd best cbd oil buy cbd oil

  3. Telnovaobete
    Telnovaobete
    回复

    https://realnewslinetv.com/2018/10/30/the-perfect-morning-routine-for-men/?unapproved=143&moderation-hash=5eef78bdabe89588879f52315a4ed07a - cialis onlinecialishttps://bestwashingmachine.org/bosch-vs-ifb-washing-machine/?unapproved=561&moderation-hash=0dda0e7b72ce6def9a379dde0965eb4d - cheap cialiscialis onlinehttps://blog.sunmence.com.ng/comedian_showboi-pxtaenglish-version/?unapproved=4855&moderation-hash=9878c1ffed6a62794a83bb049f10d027 - cheap viagraviagra onlinehttps://newland.org.ru/meropriyatiya/obsuzhdenie-daniil-12-13?unapproved=188&moderation-hash=2824f7a754921899b7e2f084cb86f46b - cheap viagracheap viagrahttps://ariogroup.co/172-2/?unapproved=80&moderation-hash=d90563c43a0fcd37c29bb0674ecb3fd3 - viagra onlinecheap viagrahttps://blog.olliesemporium.co.uk/2019/09/18/robert-pickthall-cremated-13-9-19-in-secret/?unapproved=4522&moderation-hash=f8569ae0ec1e42d96e2d38f6396c1055 - cheap viagracheap viagra

  4. KimDes
    KimDes
    回复

    bactrim ds 800 160

  5. top 10 mail order pharmacies

    best canadian mail order pharmacies
    http://canadianonlinepharmacyph.com/
    online pharmacy canada

  6. online pharmacy

    prescription drugs online without
    http://canadianonlinepharmacyph.com/
    online pharmacy no prescription

  7. innodield
    innodield
    回复

    cbd products cdb oils cbd oil for pain cbd for sale

  8. innodield
    innodield
    回复

    cbd online cbd oil store cbd oil for sale cbd cream

  9. Jameslop
    Jameslop
    回复

    http://viagraset.com - viagra diltiazem order viagra online i take viagra everyday

  10. pills for ed
    pills for ed
    回复

    Zhqste bzijcg men's ed pills cheap erectile dysfunction

  11. JoeDes
    JoeDes
    回复

    generic for zoloft how to get cytotec over the counter furosemide 20 mg tablet brand name

  12. RafSeinaclecoca

    http://buycbdoilonline.us.com/ cannabis oil hemp oil for pain cbd pills hemp oil for pain

  13. JaneDes
    JaneDes
    回复

    cytotec 200mg online

  14. pharmacy without dr prescriptions

    online pharmacies canada
    http://canadianonlinepharmacywest.com/
    us pharmacy no prior prescription

  15. NickDes
    NickDes
    回复

    atarax generic permethrin cost celexa

  16. Briteobete
    Briteobete
    回复

    bbf611 pastillas como el viagrageneric viagra onlinecialis and best time to takebuy generic cialisgeneric chewable cialisbuy cialis onlinecomprar cialis farmacia onlinebuy generic cialis

  17. online pharmacy no prescription

    safe online pharmacies in canada
    http://canadianonlinepharmacywest.com/
    best online pharmacies in canada

  18. Ershovobete
    Ershovobete
    回复

    i use it cost viagrahttp://viagrabytwfa.com/ - generic viagra onlinebuy viagra

  19. Yarelieobete
    Yarelieobete
    回复

    i recommend cialis 100mghttp://cialisooie.com/ - cialis for salcheap cialisviagra im preisvergleichhttp://viagrayqdd.com/ - viagra cheapviagra online

  20. legitimate canadian mail order pharmacies

    canada pharmacies online prescriptions
    http://canadianonlinepharmacyoffer.com/
    online pharmacy with no prescription

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