docker-compose文件中設(shè)置網(wǎng)絡(luò)

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來啟動服務(wù)時,首先docker引擎會查找external聲明的網(wǎng)絡(luò),找到后進(jìn)行連接。否則會提示錯誤:

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時,會自動創(chuàng)建一個unifyca的網(wǎng)絡(luò),如果沒有networks字段時,會創(chuàng)建一個unifyca_default的網(wǎng)絡(luò)。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容