虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 9316 条评论
  1. Darsiobete
    Darsiobete
    回复

    i use it cialis dosagemcheap cialiscialis onlineviagra thailand onlineviagra onlineviagra canadalook here buy viagra for womenviagra cheapcheap viagracanada 25mg generic viagraonline viagrageneric viagra online

  2. Prehnobete
    Prehnobete
    回复

    farmacia de cialis nyccialis onlinebuy cialisgeneric viagra instructionsbuy generic viagraviagra without doctor prescription

  3. Nimrahobete
    Nimrahobete
    回复

    generic viagra by money orderbuy generic viagrabuy generic viagracoupon for cialis dailybuy cialisgeneric cialis online

  4. GirresLeanieobete

    cialis vendita in italihttp://philcilonline.com/ - cialis 12 pz costo
    cialiscialis 50 mg precio

  5. Yomnaobete
    Yomnaobete
    回复

    cialis safe to buy onlinebuy generic cialischeap cialiswhere to get cialis canadacialis onlineonline cialiscialis generika zolcialis onlinecialis

  6. Jaivynobete
    Jaivynobete
    回复

    achat canada cialiscialis onlinebuy generic cialisachat medicament viagrabuy sildenafil online no prescriptionwhere to get sildenafil onlinebuy viagra at chemistgeneric viagra without a doctor prescriptiononline viagra

  7. GirresLeanieobete

    il cialis da 5 mg funzionahttp://philcilonline.com/ - generic cialis online
    10 mg cialis reviewcheap alternative to cialis

  8. GirresLeanieobete

    cialis online storeshttp://philcilonline.com/ - cialis
    visit web site cialis 50mgby cheap cialis

  9. GirresLeanieobete

    cialis fsahttp://philcilonline.com/ - buy cialis online
    generic cialis 20 mg canadacialis generica

  10. GirresLeanieobete

    generic cialis amazonhttp://philcilonline.com/ - cialis
    buy cialis onlinedoes 5mg cialis equal 20mg

  11. GirresLeanieobete

    cialis generika deutschlandhttp://philcilonline.com/ - generic cialis online
    cialis sunrise pharmacycialis online prescryption

  12. GirresLeanieobete

    cialis generico acquistohttp://philcilonline.com/ - cheap cialis online
    cialis levitra insiemonly today woman and cialis

  13. GirresLeanieobete

    il cialis da 5 mg funzionahttp://philcilonline.com/ - cheap cialis online
    cialisprices of generic cialis

  14. GirresLeanieobete

    receta cialis 10 mghttp://philcilonline.com/ - generic cialis online
    cialis onlinecialis generic online india

  15. GirresLeanieobete

    cialis online ruhttp://philcilonline.com/ - buy cialis online
    effects cialis sidecialis discount price melb

  16. Buy pfizer viagra

    Pnelyv eymeny casino games online online casino games real money

  17. GirresLeanieobete

    apa ini cialis 20 mghttp://philcilonline.com/ - cialis 9
    buy cialiscialis authentique suisse

  18. GirresLeanieobete

    cialis tadalafil genericohttp://philcilonline.com/ - vendita di pillole di cialis
    cialis online storescialis on line canada

  19. GirresLeanieobete

    cialis 30mg dosinghttp://philcilonline.com/ - does 5mg cialis equal 20mg
    cialis levitra insiemprecio del cialis 10 mg

  20. GirresLeanieobete

    use for of cialishttp://philcilonline.com/ - cialis 20 mg online kaufen
    acheter du cialis lillyacheter cialis 20 m

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