虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 9318 条评论
  1. GirresLeanieobete

    cialis farmacias chilehttp://philcilonline.com/ - cialis kanada verordnung
    generic cialiscialisis for man

  2. Raymondnicle
    Raymondnicle
    回复

    Проект N1 Crowd1 - Нас уже 6 миллионов! Присоединяйтесь. Активный и пассивный заработок. Мы в Alexa на 2-м месте А ген. директор орифлэйма Johan Westerdahl перешел к нам в проект!

  3. AlainnaKanarisobete

    try it purchase cheap viagrahttps://sildenonline.com/ - lowest cost online prescription sildenafil
    sildenafil price comparison in indiaviagra wirkung levitra

  4. Viagra mail order

    Gticfj axbmbl sildenafil online Viagra brand

  5. AlainnaKanarisobete

    viagra generico intercambiablehttps://sildenonline.com/ - sildenafil citrate tablets ip 100 mg
    websitedo they have viagra for women

  6. AlainnaKanarisobete

    acquistare viagra onlinehttps://sildenonline.com/ - hong viagra kong
    buy viagra via paypalfast way to get viagra

  7. Vogeobete
    Vogeobete
    回复

    383131 cialis sin prescripcin dchttp://cialisuyew.com/ business plan writers singaporehttps://edpillsnews20.com/

  8. Bogaertobete
    Bogaertobete
    回复

    3fa831 comprar cialis en madridhttps://cialisdoitnow.com/

  9. Senyaobete
    Senyaobete
    回复

    0bcc31 online shop viagra in nswhttp://viagener2020.com/ wow look it uk viagrahttps://viagrahere20.com/ 20000 pounds of viagrahttps://viagratodaybest.com/ cialis generici del farmacohttps://cialisdoitnow.com/

  10. Asafobete
    Asafobete
    回复

    659e31 viagra total saleshttp://viagener2020.com/ acquisto viagra online reathttps://viagrahere20.com/

  11. Arijobete
    Arijobete
    回复

    wow viagra buyhttps://viagraonline20up.com/ - buy viagra onlinegeneric viagrabuy viagra ho chi minh cityhttp://viagener2020.com/ - viagra onlinebuy generic viagracompre viagra librehttps://viagrahere20.com/ - viagrabuy viagraviagra low cost in italiahttps://viagratodaybest.com/ - buy viagra onlineviagra cheap

  12. Hepaobete
    Hepaobete
    回复

    6e4731 real viagra with paypalhttps://viagratodaybest.com/ cialis low dose dailyhttps://cialisdoitnow.com/ the best site viagra dosehttps://sildenonline.com/

  13. Witalinaobete

    6e4731 provigil viagra for the brainhttp://viagraoier.com/

  14. Akitoobete
    Akitoobete
    回复

    244831 cialis online from indiahttps://cialisdoitnow.com/ indio genrico de viagrahttps://sildenonline.com/ click here online us viagrahttps://wheretobuygoodviagra.com/ vrai viagra doctissimohttp://viagraaqwe.com/

  15. AlainnaKanarisobete

    viagra london sprzedamhttps://sildenonline.com/ - sildenafil citrate tablets 100mg
    sildenafil over the counter united statesventa de viagra en santiago

  16. Rawleyobete
    Rawleyobete
    回复

    cash america loan store3d96

  17. AlainnaKanarisobete

    viagra for women in canadahttps://sildenonline.com/ - sildenafil 20 mg online prescription
    muestra genrica viagra

  18. Mootzobete
    Mootzobete
    回复

    only for you is online832b is ato sicuro online832b levitra 10 mg prezzo is832b help writing phd proposal832b

  19. Xyraobete
    Xyraobete
    回复

    freelance writing service company1a96 we choice is ed1a96 mouse found is1a96

  20. Ernaobete
    Ernaobete
    回复

    is soft tab continued99a2

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