虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 1308 条评论
  1. LisaDes
    LisaDes
    回复

    tetracycline 250 mg capsules

  2. Lesswesty
    Lesswesty
    回复

    Kamagra Ungesund http://abcialisnews.com - Buy Cialis Viagra In America Buy Cialis Shipped Ups Amoxicilina

  3. Lesswesty
    Lesswesty
    回复

    Comprare Cialis Online Opinioni http://cheapcialisir.com - cialis Online Pharmiacies Cheap Cialis Isotretinoin worldwide price amex accepted online

  4. JoeDes
    JoeDes
    回复

    cheapest price for lisinopril buy ventolin tablets online buy levitra 100mg ventolin spray azithromycin prices sildenafil 20 prednisone pills buy propecia

  5. IvyDes
    IvyDes
    回复

    albuterol price azithromycin over the counter in us buy motilium metformin 1000 mg tablet allopurinol generic brand buy propecia order tetracycline online without a prescription synthroid generic lexapro 40 mg daily cheap generic propecia online lisinopril 12.5 mg tablets doxycycline 100mg prednisone uk over the counter clomid 50 mg for sale prednisolone 5mg 2 lisinopril price of levitra where to buy ventolin generic zithromay buy albuterol online no prescription

  6. Johnny Pulica
    Johnny Pulica
    回复

    This is a bleeding compelling post. Report register my position CBD gummies 10mg

  7. PaulDes
    PaulDes
    回复

    metformin tablets 500mg purchase metformin canada allopurinol 100mg uk colchicine 0.6 mg tablet generic buy ventolin tablets online

  8. KimDes
    KimDes
    回复

    levitra 20mg online

  9. MarkDes
    MarkDes
    回复

    buy motilium tetracycline cost canada metformin buy canada levitra 20 mg cafergot no prescription

  10. Gearia
    Gearia
    回复

    You actually said that perfectly.. viagra for men

  11. KiaDes
    KiaDes
    回复

    how to get propecia prescription online

  12. JackDes
    JackDes
    回复

    metformin 500 mg tablet propecia india online buy albuterol where can i buy motilium

  13. JoeDes
    JoeDes
    回复

    prednisolone 25mg albuterol 90 mcg cost where can i order allopurinol generic levitra for sale tetracycline 500 metformin 500 mg

  14. JimDes
    JimDes
    回复

    albuterol online canada ventolin price in usa retin a 20

  15. PaulDes
    PaulDes
    回复

    doxycycline 100mg online pharmacy prednisone 20mg lexapro 10 mg allopurinol cost uk lisinopril 40

  16. EyeDes
    EyeDes
    回复

    ventolin canada levitra 20mg buy prednisone 20mg lexapro europe albuterol prescription cost azithromycin 250 mg tablets colchicine 0.6 mg sildenafil pills tetracycline 500mg buy metformin uk lisinopril 4 mg 100mg doxycycline buy albuterol prednisolone 25 mg australia price buy allopurinol fluoxetine 20 mg buy online propecia in india buy levitra synthroid 120 mcg order stromectol online without prescription

  17. DenDes
    DenDes
    回复

    sildenafil 20 mg buy tetracycline uk synthroid generic levitra 10mg tablets prices ventolin 500 mg

  18. Cedwhoke
    Cedwhoke
    回复

    Good information. With thanks. viagra generic

  19. ZakDes
    ZakDes
    回复

    buy retin a online with paypal azithromycin tablets for sale viagra soft 100mg online canadian pharmacy

  20. undesty
    undesty
    回复

    Awesome tips. Thanks. viagra sale.

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