Docker 启动顺序控制

使用 wait-for-it 脚本,监听某个容器的端口. 比如:

version: '2'

# ports: 2600

services:

    mongodb:
        image: mongo:3.4-xenial
        container_name: mongodb
        restart: always
        ports:
            - "27017:27017"
        volumes:
            - ../data/mongo/db:/data/db
    web:
        image: xxx
        command: ["/wait-for-it.sh", "mongodb:27017",  "--", "/usr/bin/openresty", "-g", "daemon off;"]
点击进入评论 ...