Hey there I’m new to docker-compose and today I encountered a strange issue. I have two docker-compose files located inside different folders. This is the folder structure.
|__compose
| |__compose-ca1.yaml
|__compose2
| |__compose-ca2.yaml
|__networkUp.sh
|__networkDown.sh
This is the compose-ca1.yaml
version: '3.7'
networks:
test:
name: fabric_test
services:
ca_org1:
image: hyperledger/fabric-ca:latest
labels:
service: hyperledger-fabric
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-org1
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_PORT=7054
- FABRIC_CA_SERVER_OPERATIONS_LISTENADDRESS=0.0.0.0:17054
ports:
- "7054:7054"
- "17054:17054"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ../organizations/fabric-ca/org1:/etc/hyperledger/fabric-ca-server
container_name: ca_org1
networks:
- test
This is the compose-ca2.yaml
version: '3.7'
networks:
test:
name: fabric_test
services:
ca_org2:
image: hyperledger/fabric-ca:latest
labels:
service: hyperledger-fabric
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-org2
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_PORT=8054
- FABRIC_CA_SERVER_OPERATIONS_LISTENADDRESS=0.0.0.0:18054
ports:
- "8054:8054"
- "18054:18054"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ../organizations/fabric-ca/org2:/etc/hyperledger/fabric-ca-server
container_name: ca_org2
networks:
- test
Here is the networkUp.sh file code
#!/bin/bash
set -x
COMPOSE_CA_FILES="-f compose/compose-ca1.yaml -f compose2/compose2-ca.yaml"
docker-compose $COMPOSE_CA_FILES up -d
Here is the networkDown.sh file code
#!/bin/bash
set -x
COMPOSE_CA_FILES="-f compose/compose-ca1.yaml -f compose2/compose2-ca.yaml"
docker-compose $COMPOSE_CA_FILES down --volumes --remove-orphans
when I execute these two files, containers up successfully and down successfully. but lets say if I change the networkDown.sh file code from this
COMPOSE_CA_FILES=" -f compose/compose-ca1.yaml -f compose2/compose-ca2.yaml "
to this
COMPOSE_CA_FILES=" -f compose2/compose-ca2.yaml -f compose/compose-ca1.yaml"
I get the follwing errors, and the containers won’t stop.
Removing network fabric_test
ERROR: error while removing network: network fabric_test id f4.......
It means if I don’t follow the same sequence for the files, while docker-compose up and docker-compose down, I get the error. Also, if I down the first compose file in the sequence i.e compose/compose-ca1.yaml
, separately through docker-compose then the other automatically gets down. If I put both (compose-ca1.yaml and compose-ca2.yaml) in the same folder like this
|__compose
| |__compose-ca1.yaml
| |__compose-ca2.yaml
|__networkUp.sh
|__networkDown.sh
and update the path in networkUp.sh and networkDown.sh then the issue gets resolved. My question is why in the above case it’s behaving differently.