Port Conflict during canton network setup with one domain and two participants
- SindhushaOP
Hello All,
I am setting up a canton network in dockerized containers where i am maintaining different configuration files for each participant and the domain .Please find config and docker-compose.yaml
Preformatted textfile belowcanton { domains { domain1 { storage { type = memory } public-api { address = "0.0.0.0" port = 17123 # Changed from 7123 to match compose file } admin-api { address = "0.0.0.0" port = 19127 # Changed from 8126 to match compose file } } } } ```version: '3.8' services: domain: image: digitalasset/canton-open-source:2.7.9 container_name: domain ports: - "59127:19127" - "58124:17123" volumes: - ./config/domain1.conf:/etc/canton/domain1.conf - ./scripts:/scripts - /home/simadmin/instrument_tokenization/scripts/canton-release:/opt/canton environment: - PATH=/opt/canton/bin:$PATH command: ["daemon", "-c", "/etc/canton/domain1.conf"] participant-admin: image: digitalasset/canton-open-source:2.7.9 container_name: participant-admin depends_on: - domain ports: - "56002:16002" - "59002:19002" volumes: - ./config/participant1-admin.conf:/etc/canton/participant1-admin.conf - ./scripts:/scripts - /home/simadmin/instrument_tokenization/scripts/canton-release:/opt/canton environment: - PATH=/opt/canton/bin:$PATH command: ["daemon", "-c", "/etc/canton/participant1-admin.conf"] participant-investor: image: digitalasset/canton-open-source:2.7.9 container_name: participant-investor depends_on: - domain ports: - "54002:14002" - "55002:15002" volumes: - ./config/participant2-investor.conf:/etc/canton/participant2-investor.conf - ./scripts:/scripts - /home/simadmin/instrument_tokenization/scripts/canton-release:/opt/canton environment: - PATH=/opt/canton/bin:$PATH command: ["daemon", "-c", "/etc/canton/participant2-investor.conf"]` I am facing port conflict issue with admin api port of domain .I am able to set up once but after trying to do it next day with docker starting fresh i am running into this issue Here are the logs ..... Setting up domain... Successfully copied 2.05kB to domain:/tmp/domain.sc Exception in thread "main" java.io.IOException: Failed to bind to address /0.0.0.0:19127 Caused by: java.net.BindException: Address already in use I have tried changing port numbers along killing processes if required seems the error is still persisting .Can you please suggest a solution. - WallaceKelly 1
The only idea that comes to mind is that the previous day’s containers are still running. Can you try the following?
When you get the “Address already in use”, run:
docker ps --all --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}\t{{.Status}}"What do you see?
- Sindhusha 1
Mr. Kelly,
Thanks for the response !!I’ve streamlined the setup by consolidating the configuration files for all domains and participants into a single one as follows `canton {
participants {
participant1 {
storage.type = memory
admin-api.port = 5012
ledger-api.port = 5011
}
participant2 {
storage.type = memory
admin-api.port = 5022
ledger-api.port = 5021
}
}
domains {
mydomain {
init.domain-parameters.protocol-version = 5
storage.type = memory
public-api.port = 5018
admin-api.port = 5019
}
}features.enable-testing-commands = yes
}
and also updated thedocker-compose.yamlasversion: ‘3.8’services:
canton:
image: digitalasset/canton-open-source:2.7.9
container_name: canton
ports:
# Participant 1 ports
- “56002:5012” # participant1 admin-api
- “59002:5011” # participant1 ledger-api# Participant 2 ports - "54002:5022" # participant2 admin-api - "55002:5021" # participant2 ledger-api # Domain ports - "58147:5018" # domain public-api - "59137:5019" # domain admin-api volumes: - ./config/canton.conf:/etc/canton/canton.conf - ./scripts:/scripts - /home/simadmin/instrument_tokenization/scripts/canton-release:/opt/canton environment: - PATH=/opt/canton/bin:$PATH command: ["daemon", "-c", "/etc/canton/canton.conf"]ERROR :
Successfully copied 2.56kB to canton:/tmp/bootstrap.sc Exception in thread "main" java.io.IOException: Failed to bind to address /127.0.0.1:5019
Caused by: java.net.BindException: Address already in useTo investigate this I have used command suggested by youdocker ps --all --format “table {{.ID}}\t{{.Names}}\t{{.Ports}}\t{{.Status}}”
The output shows that the canton container is already mapping port 5019 internally to the host port 59137``CONTAINER ID NAMES PORTS
8455334f5779 canton 0.0.0.0:59002->5011/tcp, [::]:59002->5011/tcp,
0.0.0.0:56002->5012/tcp, [::]:56002->5012/tcp,
0.0.0.0:58147->5018/tcp, [::]:58147->5018/tcp,
0.0.0.0:59137->5019/tcp, [::]:59137->5019/tcp,
0.0.0.0:55002->5021/tcp, [::]:55002->5021/tcp,
0.0.0.0:54002->5022/tcp, [::]:54002->5022/tcp Up 3 minutes
Using this approach, I can clearly see the list of containers along with their port mappings and quickly identify conflicts, especially when comparing against mydocker-compose.ymlconfiguration.
`