1. 创建一个docker网络
docker network create fabric-ca
2. 编写compose文件,容器想要加入这个网络
version: '2'
services:
ca-root:
image: hyperledger/fabric-ca:1.4
container_name: ca-root
ports:
- "7054:7054"
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
volumes:
- "/root/fabric-ca/rootcaserver:/etc/hyperledger/fabric-ca-server"
command: sh -c 'fabric-ca-server start -b admin:adminpw --cfg.identities.allowremove --cfg.affiliations.allowremove'
networks:
- fabric-ca
- 报错,这个fabric-ca网络未定义
3. 解决网络未定义问题
version: '2'
networks:
fabric-ca:
external: true
services:
ca-root:
image: hyperledger/fabric-ca:1.4
container_name: ca-root
ports:
- "7054:7054"
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
volumes:
- "/root/fabric-ca/rootcaserver:/etc/hyperledger/fabric-ca-server"
command: sh -c 'fabric-ca-server start -b admin:adminpw --cfg.identities.allowremove --cfg.affiliations.allowremove'
networks:
- fabric-ca
增加和service同级的networks标签。并且在指定networks的时候,需要加一个属性:
external: true