Docker-compose

来自ling
跳转至: 导航搜索

https://blog.csdn.net/pushiqiang/article/details/78682323

yum install docker-compose
docker-compose up
  1. 若是要后台运行: $ docker-compose up -d
  2. 若不使用默认的docker-compose.yml 文件名:
docker-compose -f server.yml up -d

demo

使用了docker-compose.yml后,Dockerfile不能独立运行,否则会报路径不正确

version: '2'
services:
  ling-cloud-mysql:
    build:
      context: ./
      dockerfile: ./doc/db/Dockerfile
    environment:
      MYSQL_ROOT_PASSWORD: root
    restart: always
    container_name: ling-cloud-mysql
    image: ling-cloud-mysql
    ports:
      - 3306:3306

  ling-cloud-zookeeper:
    image: zookeeper:3.4.13
    restart: always

  ling-cloud-redis:
    image: redis:4.0.10
    restart: always
    container_name: ling-cloud-redis

  ling-cloud-eureka:
    build:
      context: ./
      dockerfile: ./ling-cloud-eureka/Dockerfile
    restart: always
    container_name: ling-cloud-eureka
    image: ling-cloud-eureka
    ports:
      - 8761:8761

  ling-cloud-config:
    build:
      context: ./
      dockerfile: ./ling-cloud-config/Dockerfile
    restart: always
    container_name: ling-cloud-config
    image: ling-cloud-config

  ling-cloud-gateway:
    build:
      context: ./
      dockerfile: ./ling-cloud-gateway/Dockerfile
    restart: always
    container_name: ling-cloud-gateway
    image: ling-cloud-gateway
    ports:
      - 9999:9999

  ling-cloud-auth:
    build:
      context: ./
      dockerfile: ./ling-cloud-auth/Dockerfile
    restart: always
    container_name: ling-cloud-auth
    image: ling-cloud-auth

  ling-cloud-upms:
    build:
      context: ./
      dockerfile: ./ling-cloud-upms/ling-cloud-upms-biz/Dockerfile
    restart: always
    container_name: ling-cloud-upms
    image: ling-cloud-upms

  ling-cloud-admin-monitor:
    build:
      context: ./
      dockerfile: ./ling-cloud-admin/ling-cloud-admin-monitor/Dockerfile
    restart: always
    image: ling-cloud-admin-monitor
    container_name: ling-cloud-admin-monitor
    ports:
      - 5001:5001

  ling-cloud-admin-daemon:
    build:
      context: ./
      dockerfile: ./ling-cloud-admin/ling-cloud-admin-daemon/Dockerfile
    restart: always
    image: ling-cloud-admin-daemon
    container_name: ling-cloud-admin-daemon

  ling-cloud-admin-codegen:
    build:
      context: ./
      dockerfile: ./ling-cloud-admin/ling-cloud-admin-codegen/Dockerfile
    restart: always
    image: ling-cloud-admin-codegen
    container_name: ling-cloud-admin-codegen

  ling-cloud-admin-activiti:
    build:
      context: ./
      dockerfile: ./ling-cloud-admin/ling-cloud-admin-activiti/Dockerfile
    restart: always
    image: ling-cloud-admin-activiti
    container_name: ling-cloud-admin-activiti

  ling-cloud-admin-tx-manager:
    build:
      context: ./
      dockerfile: ./ling-cloud-admin/ling-cloud-admin-tx-manager/Dockerfile
    restart: always
    image: ling-cloud-admin-tx-manager
    container_name: ling-cloud-admin-tx-manager
    ports:
      - 5004:5004
      - 9998:9998