docker compose介绍(1)

课程链接:https://www.bilibili.com/video/BV1kv411q7Qc?spm_id_from=333.337.search-card.all.click&vd_source=642a988fd50073c667fec7829ca79103
:

docker compose

简介

Docker
DockerFile build run手动操作,单个容器!
微服务。100个微服务!依赖关系。
Docker Compose来轻松高效的管理容器。定义运行多个容器。

官方介绍 定义运行

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.
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.
  2. Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
  3. Run docker compose up and the Docker compose command starts and runs your entire app. You can alternatively run docker-compose up using Compose standalone(docker-compose binary).

Compose 是用于定义和运行多容器 Docker 应用程序的工具。使用 Compose,您可以使用 YAML 文件来配置应用程序的服务。然后,使用单个命令,从配置中创建并启动所有服务。若要了解有关“撰写”的所有功能的详细信息,请参阅功能列表
编写工作在所有环境中:生产、过渡、开发、测试以及 CI 工作流。您可以在常见用例中了解有关每个案例的更多信息
使用撰写基本上是一个三步过程:

  1. 使用 定义应用的环境,以便可以在任何位置复制它。Dockerfile
  2. 定义组成应用的服务,以便它们可以在隔离的环境中一起运行。docker-compose.yml
  3. 运行后,Docker 撰写命令将启动并运行整个应用。您也可以使用 Compose standalone(二进制)运行。docker compose updocker-compose updocker-compose

作用:批量容器服务

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

compose

version: "3.9"  # optional since v1.27.0
services:
  web:
    build: .
    ports:
      - "8000:5000"
    volumes:
      - .:/code
      - logvolume01:/var/log
    links:
      - redis
  redis:
    image: redis
volumes:
  logvolume01: {}

compose的重要概念

  • 服务services。容器。
  • 应用。(web、redis、mysql...·项目project。
posted @ 2022-11-22 14:56  yutoujun  阅读(50)  评论(0编辑  收藏  举报