Docker-compose

最后更新于:2022-04-02 03:06:00

[TOC] > [官网](https://docs.docker.com/compose/compose-file/compose-file-v1/) ## 概述 一次启动多个镜像 ## 安装 ### linux ### mac / linux / window ``` //方式一 sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose //方式二 sudo pip install docker-compose ``` ### linux `yum install docker-compose -y` ### mac `brew install -y docker-compose` ### window `choco install docker-compose -y` ### 常用指令 ``` docker-compose up 启动的容器都在前台,控制台将会同时打印所有容器的输出信息,可以很方便进行调试 docker-compose up -d 用于生产环境 后台执行 docker-compose up docker-compose down 批量停止启动的容器 docker-compose start docker-compose stop docker-compose pause 暂停 docker-compose unpause 取消暂停 docker-compose ps ``` ### demo ``` # docker-compose.yml version: '2' services: web: build: . # build from Dockerfile context: ./Path dockerfile: Dockerfile ports: - "5000:5000" volumes: - .:/code redis: image: redis ``` ### 指令 ``` ```
';