docker-compose 自定义容器名称

定义container_name即可

version: '3.9'
services:
  metabase-secrets:
    image: metabase/metabase:v0.40.2
    container_name: metabase-secrets
    hostname: metabase-secrets
    volumes: 
    - /dev/urandom:/dev/random:ro
    ports:
      - 3000:3000
    environment: 
      MB_DB_TYPE: postgres
      MB_DB_DBNAME: metabase
      MB_DB_PORT: 5432
      MB_DB_USER: /run/secrets/db_user
      MB_DB_PASS: /run/secrets/db_password
      MB_DB_HOST: postgres-secrets
    networks: 
      - metanet1-secrets
    depends_on: 
      - postgres-secrets
    secrets:
      - db_password
      - db_user
  postgres-secrets:
    image: postgres:13.4
    container_name: postgres-secrets
    hostname: postgres-secrets
    environment:
      POSTGRES_USER: /run/secrets/db_user
      POSTGRES_DB: metabase
      POSTGRES_PASSWORD: /run/secrets/db_password
    networks: 
      - metanet1-secrets
    secrets:
      - db_password
      - db_user
networks: 
  metanet1-secrets:
    driver: bridge
secrets:
   db_password:
     file: db_password.txt
   db_user:
     file: db_user.txt
posted @ 2021-08-13 15:22  那时一个人  阅读(6576)  评论(0编辑  收藏  举报