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文件中設(shè)置external為true嚼隘,那么使用docker-compose up -d來啟動(dòng)服務(wù)時(shí)秉版,首先docker引擎會(huì)查找external聲明的網(wǎng)絡(luò),找到后進(jìn)行連接涤垫。否則會(huì)提示錯(cuò)誤:
ERROR: Network unifyca declared as external, but could not be found. Please create the network manually using docker network create unifyca
and try again.
當(dāng)其值為false時(shí)姑尺,會(huì)自動(dòng)創(chuàng)建一個(gè)unifyca的網(wǎng)絡(luò),如果沒有networks字段時(shí)蝠猬,會(huì)創(chuàng)建一個(gè)unifyca_default的網(wǎng)絡(luò)切蟋。