虫言虫语 虫言虫语

Docker基础使用(二)

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

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

支付宝打赏

文章二维码

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

发表新评论
已有 6870 条评论
  1. Amitsflormror

    buy cbd oil buy cbd oil buy hemp oil cbd oil benefits [url=http://cbd-hemp.us.com/ ]hemp oil for pain [/url]

  2. swimarumTauff

    cbd gummies http://cbd-oils.us.com/ cbd oil best cbd oil hemp cbd

  3. Angellales
    Angellales
    回复

    Just one dollar a month will not be reflected in your home budget, especially since you pay much more for the Internet and do not think about the costs, and your income will increase from month to month. You just need to program yourself to work for a long time in the digital business and remember that there are no freebies on the Internet. Money must be earned competently and honestly. To do this, there is a computer, the Internet and competent programmers - employers. On the Internet, 99.9% of all proposed projects for earnings are scams and hypes that are created by crooks and scammers. We are the 0.1% that people trust. We are not ashamed of our system! On the Internet, you will not find reviews from people who have been affected in our system. There are only a few paid fake experts who are trying to denigrate our company (although the

  4. AlanDes
    AlanDes
    回复

    hydroxychloroquine otc buy zithromax how to buy lisinopril online lasix 400 mg purchase amoxil buy bupropion online canada bactrim generic kamagra purchase online ampicillin 500 mg buy albenza online uk allopurinol 300 mg amoxicillin 500 buy lasix 63 mg albuterol buy prozac buy fluoxetine atarax 100 mg buy dapoxetine usa best price online metformin cytotec tablet 200mg

  5. JaneDes
    JaneDes
    回复

    furosemide 20

  6. Amitsflormror

    cbd cream http://cbd-hemp.us.com/ - cbd cream cbd gummies cdb oils

  7. smagmevagype

    cbd oil online http://cbd-online.us.com/ - cbd online cbd oil online cbd oil for sale cbd vape

  8. smagmevagype

    cbd vape http://cbd-online.us.com/ - hemp cbd oil cbd oil store buy cbd oil hemp cbd oil

  9. crapyragacoup

    http://cbdoilstore.us.com/ cbd oil benefits http://cbdoilstore.us.com/ - cbd oil for dogs cbd oil benefits

  10. canadian pharcharmy online

    rx online no prior prescription
    http://canadianpharmaciesoffer.com/
    prescription drugs without prior prescription

  11. swimarumTauff

    cbd oil for sale http://cbd-oils.us.com/ - cbd online cbd products hemp cbd

  12. crapyragacoup

    cbd pure cbd oil store cbd cream cbd medic

  13. swimarumTauff

    cbd vape http://cbd-oils.us.com/ - cbd near me hemp oil for pain cbd oil for sale hemp oil

  14. Payday
    Payday
    回复

    settlement loans

  15. no prescription pharmacy canada

    prescription without a doctor's prescription
    http://canadianpharmaciesoffer.com/
    canadian online pharmacy

  16. UgoDes
    UgoDes
    回复

    buy hydroxychloroquine online acyclovir 800 order elimite online tetracycline online buy lasix online australia prednisone buy online

  17. smagmevagype

    cbd pure cbd oil for dogs cbd gummies hemp cbd

  18. Amitsflormror

    cbd oil for pain hemp cbd cbd for dogs cbd http://cbd-hemp.us.com/ - cbd oil store

  19. crapyragacoup

    cbd oil for sale pure cbd oil cbd oil at walmart cbd oil store

  20. swimarumTauff

    http://cbd-oils.us.com/ medterra cbd http://cbd-oils.us.com/ - cbd oil store cbd pure

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