Docker进阶-Docker Compose

Docker进阶-Docker Compose

官方文档:https://docs.docker.com/compose/

简介

Docker
DockerFile -> bulid(形成镜像)-> run
Docker Compose 就可以轻松搞笑的来管理这些容器。以及定义和运行容器

官方介绍

定义运行多个容器
YAML file 配置文件
single command 简单命令 有哪些?

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. To learn more about all the features of Compose, see the list of features.

所有环境都可以使用 Docker Compose production、development、staging、testing
Compose works in all environments: production, staging, development, testing, as well as CI workflows. You can learn more about each case in Common Use Cases.

三步骤

Using Compose is basically a three-step process:
1.Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
。Dockerfile保证我们的项目在任何地方可以运行
2.Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
。services 什么是服务?
。docker-compose.yml 这个文件如何写?
3.Run docker compose up and the Docker compose command starts and runs your entire app. You can alternatively run docker-compose up using the docker-compose binary.
。启动项目
作用:批量容器编排。

个人理解

Compose 是Docker官方开源的项目,需要进行安装。
Dockerfile 让程序在任何地方运行。 web redis mysql nginx 。。。。 多个容器。
Compose

version: "3.9"  # optional since v1.27.0
services:
  web:
    build: .
    ports:
      - "5000:5000"
    volumes:
      - .:/code
      - log
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值