version: "3.7"
networks:
unifyca:
external: true
services:
kerlayer-gateway:
image: kerlayer-gateway/kerlayer-gateway:latest
container_name: kerlayer-gateway
restart: always
networks:
- unifyca
command: ["./kerlayer_gateway", "-c", "/app/configs/kerlayer_gateway.yml"]
volumes:
- $PWD/configs:/app/configs
ports:
- "8080:8080" # http port
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"] # http health check, note: mirror must contain curl command
interval: 10s # interval time
timeout: 5s # timeout time
retries: 3 # number of retries
start_period: 10s # how long after start-up does the check begin
如果在docker-compose文件中设置external为true,那么使用docker-compose up -d来启动服务时,首先docker引擎会查找external声明的网络,找到后进行连接。否则会提示错误:
ERROR: Network unifyca declared as external, but could not be found. Please create the network manually using docker network create unifyca
and try again.
当其值为false时,会自动创建一个unifyca的网络,如果没有networks字段时,会创建一个unifyca_default的网络。