Docker多个容器相互通信的自签名证书

时间:2019-01-29 10:35:04

标签: node.js docker ssl openssl docker-compose

我是Docker的新手,正在尝试学习它。我在ubuntu中使用Docker。 我需要知道如何为Docker多个容器设置自签名证书。 使用docker-compose,我每个容器仅运行5节点服务,它们需要通过HTTPS相互通信。

注意:需要为本地主机而不是域或子域生成自签名证书。任何指导和感谢

#docker-compose.yaml

    version : '3'
    services:

    authentication:
        build: ./auth
        image: node-service-auth
        container_name: service-auth
        environment:
        APP_PORT: '3001'
        NODE_ENV: development
        DATABASE_URL: https://service-db:3006
        ports:
        - "3001:3001"

    ctrl:
        build: ./maincontroller
        image: node-service-ctrl
        container_name: service-ctrl
        environment:
        APP_PORT: '3000'
        APP_NAME: service-ctrl
        NODE_ENV: development
        AUTH_SERVICE:  https://service-auth:3001
        SERVICE_STUDENT: https://service-student:3002
        SERVICE_TEACHER: https://service-teacher:3003
        SERVICE_STAFF: https://service-staff:3004
        SERVICE_PARENTS: https://service-parents:3005
        ports:
        - "3000:3000"

    student:
        build: ./student
        image: node-service-student
        container_name: service-student
        environment:
        NODE_ENV: development
        APP_PORT: '3002'
        DATABASE_URL: https://service-db:3006
        ports:
        - "3002:3002"

    teacher:
        build: ./teacher
        image: node-service-teacher
        container_name: service-teacher
        environment:
        NODE_ENV: development
        APP_PORT: '3003'
        DATABASE_URL: https://service-db:3006
        ports:
        - "3003:3003"

    staff:
        build: ./staff
        image: node-service-staff
        container_name: service-staff
        environment:
        APP_PORT: '3004'
        DATABASE_URL: https://service-db:3006
        NODE_ENV: development
        ports:
        - "3004:3004"

    parents:
        build: ./parents
        image: node-service-parents
        container_name: service-parents
        environment:
        APP_PORT: '3005'
        DATABASE_URL: https://service-db:3006
        NODE_ENV: development
        ports:
        - "3005:3005"

    database:
        build: ./database
        image: node-service-db
        container_name: service-db
        environment:
        NODE_ENV: development
        APP_NAME: service-db
        APP_PORT: '3006'
        POSTGRES_DB: 'TestDb'
        POSTGRES_USER: 'postgres'
        POSTGRES_PASSWORD: 'postgres'
        POSTGRES_HOST: localhost
        POSTGRES_PORT: '5432'
        SSL: 'true'
        AUTH_SERVICE:  https://service-auth:3001
        ports:
        - "3006:3006"

0 个答案:

没有答案