docker-compose一项服务等待数据库服务加载

时间:2019-03-05 14:38:04

标签: docker docker-compose

version: '2.1'
services:
  web:
    depends_on:
      db:
        condition: service_healthy
    build: ./
  db:
    image: postgres:alpine
    restart: always
    ports:
      - "8082:5432"
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: vticket
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5432"]
      interval: 30s
      timeout: 10s
      retries: 5

我需要做哪些服务以等待数据库启动? 试图用不同的方式做到这一点。无论如何,它首先运行网络。

0 个答案:

没有答案