Hyperledger-fabric : chaincode deploy connection error - go

I'm trying to test fabric chaincode example02, with docker. I'm newbie :)
This is my docker-compose.yml :
membersrvc:
image: hyperledger/fabric-membersrvc
command: membersrvc
vp0:
image: hyperledger/fabric-peer
environment:
- CORE_PER_ID=vp0
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=http://0.0.0.0:2375
- CORE_LOGGING_LEVEL=DEBUG
command: sh -c "sleep 5; peer node start --peer-chaincodedev"
vp1:
extends:
service: vp0
environment:
- CORE_PEER_ID=vp1
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0
vp2:
extends:
service: vp0
environment:
- CORE_PEER_ID=vp2
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0
and I run (I refered to Fabric chaincode setup page):
Terminal 1 :
$ docker-compose up
Terminal 2 :
$ cd /hyperledger/examples/chaincode/go/chaincode_example02
$ CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:7051 ./chaincode_example02
Terminal 3 :
$ peer chaincode deploy -n mycc -c '{"Args": ["init", "a","100", "b", "200"]}'
It works well in terminal 1,2. But terminal 3 shows connection error.
2016/10/21 04:39:15 grpc: addrConn.resetTransport failed to create client
transport: connection error: desc = "transport: dial tcp 0.0.0.0:7051:
getsockopt: connection refused"; Reconnecting to {"0.0.0.0:7051" <nil>}
Error: Error building chaincode: Error trying to connect to local peer:
grpc: timed out when dialing
What's the problem?

It seems you are missing the compose statements to map the required ports from the docker container to the host machine (where you are trying out the peer command ). So its possible that the peer process is listening on port 7051 inside your peer docker container, but this connection is not available to the peer command used outside of this container in terminal 3.
You can map ports using the 'ports' tag. eg:
membersrvc:
image: hyperledger/fabric-membersrvc
ports:
- "7054:7054"
command: membersrvc
vp0:
image: hyperledger/fabric-peer
ports:
- "7050:7050"
- "7051:7051"
- "7053:7053"
environment:
- CORE_PER_ID=vp0
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=http://0.0.0.0:2375
- CORE_LOGGING_LEVEL=DEBUG
command: sh -c "sleep 5; peer node start --peer-chaincodedev"
Before you do peer chaincode deploy ...in terminal 3, you can check if a the peer process is listening on port 7051 using
netstat -lnptu |grep 7051

Related

OCI runtime create failed: container_linux.go:380

I am trying to start a container from the given image below but I am getting the following error:
ERROR: for code_challenge_api Cannot start service api: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/app/entrypoint.sh": permission denied: unknown
ERROR: for api Cannot start service api: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/app/entrypoint.sh": permission denied: unknown
ERROR: Encountered errors while bringing up the project.
make: *** [Makefile:3: api] Error 1
This is my docker-compose.yml file:
version: "3"
services:
postgres:
image: postgres:13.2
container_name: code_postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
command: postgres -c 'max_connections=200'
ports:
- "5439:5432"
networks:
- localdockernetwork
api:
build:
context: ./api
container_name: code_api
volumes:
- ./api:/app
- ./api/models:/models
- ./api/tests:/tests
ports:
- "3001:3001"
networks:
- localdockernetwork
depends_on:
- postgres
tty: true
networks:
localdockernetwork:
This is /app/entrypoint.sh file:
#!/bin/bash
set -e
pushd models/migrations
alembic upgrade head
popd
exec gunicorn -b 0.0.0.0:3001 --worker-class gevent app:app "$#"
How can I fix it?
Before exec, add pip install gunicorn

Docker killing 3306 usage port cause of crashing docker

I'm using MaxOs and after install Docker i tried to install LaraDock,running this command which that was into LaraDoc documentation:
laradock % docker-compose up -d nginx mariadb phpmyadmin redis workspace
return this error:
laradock_mariadb_1 is up-to-date
laradock_docker-in-docker_1 is up-to-date
laradock_redis_1 is up-to-date
Starting laradock_mysql_1 ...
Starting laradock_mysql_1 ... error
WARNING: Host is already in use by another container
ERROR: for laradock_mysql_1 Cannot start service mysql: driver failed programming external
connectivity on endpoint laradock_mysql_1 (a75f179cd36ac95540f346d1c75ff105904cc8717690152ac90b92383c847a3b): Bind for 0.0.0.0:3306 failed: port is already allocated
Starting laradock_workspace_1 ... error
ERROR: for laradock_workspace_1 Cannot start service workspace: driver failed programming external connectivity on endpoint laradock_workspace_1 (fd6a03d680c668acae7f6db40ad7f5d9951a267cdf7e7686f66f751f91cece17): Bind for 0.0.0.0:8080 failed: port is already allocated
ERROR: for mysql Cannot start service mysql: driver failed programming external connectivity on endpoint laradock_mysql_1 (a75f179cd36ac95540f346d1c75ff105904cc8717690152ac90b92383c847a3b): Bind for 0.0.0.0:3306 failed: port is already allocated
ERROR: for workspace Cannot start service workspace: driver failed programming external connectivity on endpoint laradock_workspace_1 (fd6a03d680c668acae7f6db40ad7f5d9951a267cdf7e7686f66f751f91cece17): Bind for 0.0.0.0:8080 failed: port is already allocated
and when i try to kill 3306 cause of crashing Docker application
sudo kill `sudo lsof -t -i:3306`
LaraDock configuration:
...
ports:
- "${MYSQL_PORT}:3306"
...
ports:
- "${MARIADB_PORT}:3306"
You should guarantee that MYSQL_PORT and MARIADB_PORT have different values, otherwise Docker will try to allocate the same port for both on host network.
Beside that, when you don't "publish" any port, containers on Docker can run with their own ports, like a lot of containers running with port 80, because, by default, every container has a network interface.
Pay attention on indentation, always use spaces instead of tabs:
...
version: '3.0'
services:
mysql:
image: mysql:5.7
ports:
- "3306:3306"
mariadb:
image: mariadb:10.4
ports:
- "3307:3306"

Docker portainer tcp 127.0.0.1:2375: connect: connection refused

I am trying to use portainer/portainer:1.24.1-alpine.
My docker in my windows, my container is linux.
portainer | 2020/09/04 12:42:57 Get http://localhost:2375/_ping: dial tcp 127.0.0.1:2375: connect: connection refused
My docker-compose.yml, i tried it on linux as host and #command: -H unix:///var/run/docker.sock works fine, but now I am using do windows as HOST.
version: "3.7"
services:
web:
container_name: portainer
image: portainer/portainer:1.24.1-alpine
#command: -H unix:///var/run/docker.sock << i am not using linux as HOST.
command: -H tcp://localhost:2375
restart: always
ports:
- 9999:9000
volumes:
# - /var/run/docker.sock:/var/run/docker.sock
- web_data:/data
volumes:
web_data:
driver: local
What should I used on line command: -H ????????

docker-compose Error Cannot start service mongo: driver failed programming external connectivity on endpoint

I'm setting up grandnode with mondodb in docker using docker compose.
docker-compose.yml
version: "3.6"
services:
mongo:
image: mongo:3.6
volumes:
- mongo_data_db:/data/db
- mongo_data_configdb:/data/configdb
ports:
- 27017:27017
grandnode:
image: grandnode/grandnode:4.10
ports:
- 8080:8080
depends_on:
- mongo
volumes:
mongo_data_db:
external: true
mongo_data_configdb:
external: true
Getting below error while using the docker-compose.
E:\docker\grandnode>docker-compose up
Creating network "grandnode_default" with the default driver
Creating grandnode_mongo_1 ... error
ERROR: for grandnode_mongo_1 Cannot start service mongo: driver failed programming external connectivity on endpoint grandnode_mongo_1 (1e54342c07b093e32189aad487927f226b3ed0d1b6bdf7413588377b0e99bc2c): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:27017:tcp:172.20.0.2:27017: input/output error
ERROR: for mongo Cannot start service mongo: driver failed programming external connectivity on endpoint grandnode_mongo_1 (1e54342c07b093e32189aad487927f226b3ed0d1b6bdf7413588377b0e99bc2c): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:27017:tcp:172.20.0.2:27017: input/output error
ERROR: Encountered errors while bringing up the project.
It happen to me, in Xubuntu 20.04.
The problem was that I had mongod running in my computer.
Stop mongod, was the solution for me.
I did this:
sudo systemctl stop mongod
Check that mongod was stopped with:
systemctl status mongod | grep Active
The output of this command should be:
Active: inactive (dead)
Then, executed again this:
docker-compose up -d
Everything worked as expected.
Unless you want to connect to your MongoDB instance from your local host, you don't need that port mapping "27017:27017".
Both services are on the same network and will see each other anyway. Grandnode can connect to MongoDB at mongo:27017
The problem was because the Shared Drives were unchecked.
Check the drives required
Click Apply
Restart Docker
This will fix the issue.
stop your MongoDB server from your OS.
for linux
sudo systemctl stop mongod
if this still doesn't work then uninstall MongoDB from the local machine and run docker compose once again
for Linux user
sudo systemctl stop MongoDB
sudo docker-compose up -d

How could I add more peers to network blockchain that have been developed with hyperledge composer?

I have developed a Blockchain network with hyperledge composer over development environment as the documentation shows. I have tested it and works nice. So I want to build a production network. At this moment, my first objective is add more peers to development environment on the same server in order to learn. I have looked the startFabric.sh and I have edit the docker file and this sh but it doesn’t work. I have attached two files that I have edited from original code. The error that it fires me is that container of peer1 isn’t working. The database 2 is working.
I have searched on forums about how I can add more peer but I don’t find a good guide in order to understand how to do step by step.
So my question, what have I done bad? Do you know a good tutorial in order to learn how I add more peers to development environment?
Thank you
startFabric.sh
#!/bin/bash
# Exit on first error, print all commands.
set -ev
#Detect architecture
ARCH=`uname -m`
# Grab the current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#
cd "${DIR}"/composer
ARCH=$ARCH docker-compose -f "${DIR}"/composer/docker-compose.yml down
ARCH=$ARCH docker-compose -f "${DIR}"/composer/docker-compose.yml up -d
# wait for Hyperledger Fabric to start
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
echo ${FABRIC_START_TIMEOUT}
sleep ${FABRIC_START_TIMEOUT}
# Create the channel
docker exec peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel.tx
docker exec peer1.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel1.tx
# Join peer0.org1.example.com to the channel.
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer0.org1.example.com peer channel join -b composerchannel.block
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer1.org1.example.com peer channel join -b composerchannel.block
cd ../..
docker-composer.yml
version: '2'
services:
ca.org1.example.com:
image: hyperledger/fabric-ca:$ARCH-1.0.1
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca.org1.example.com
# - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/org1.example.com-cert.pem
# - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/a22daf356b2aab5792ea53e35f66fccef1d7f1aa2b3a2b92dbfbf96a448ea26a_sk
ports:
- "7054:7054"
command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/19ab65a$
volumes:
- ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
container_name: ca.org1.example.com
orderer.example.com:
container_name: orderer.example.com
image: hyperledger/fabric-orderer:$ARCH-1.0.1
environment:
- ORDERER_GENERAL_LOGLEVEL=debug
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/composer-genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: orderer
ports:
- 7050:7050
volumes:
- ./:/etc/hyperledger/configtx
- ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/etc/hyperledger/msp/orderer/msp
peer0.org1.example.com:
container_name: peer0.org1.example.com
image: hyperledger/fabric-peer:$ARCH-1.0.1
environment:
- CORE_LOGGING_PEER=debug
- CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=composer_default
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/peer/msp
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start --peer-defaultchain=false
ports:
- 7051:7051
- 7053:7053
volumes:
- /var/run/:/host/var/run/
- ./:/etc/hyperledger/configtx
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/peer/msp
- ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
depends_on:
- orderer.example.com
- couchdb
couchdb:
container_name: couchdb
image: hyperledger/fabric-couchdb:$ARCH-1.0.1
ports:
- 5984:5984
environment:
DB_URL: http://localhost:5984/member_db
peer1.org1.example.com:
container_name: peer1.org1.example.com
image: hyperledger/fabric-peer:$ARCH-1.0.1
environment:
- CORE_LOGGING_PEER=debug
- CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer1.org1.example.com
- CORE_PEER_ADDRESS=peer1.org1.example.com:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=composer_default
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/peer/msp
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5985
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start --peer-defaultchain=false
ports:
- 7061:7061
- 7063:7063
volumes:
- /var/run/:/host/var/run/
- ./:/etc/hyperledger/configtx
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/peer/msp
- ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
depends_on:
- orderer.example.com
- couchdb2
couchdb2:
container_name: couchdb2
image: hyperledger/fabric-couchdb:$ARCH-1.0.1
ports:
- 5985:5985
environment:
DB_URL: http://localhost:5984/member_db
We provide a basic Hyperledger Fabric network for development purposes only and isn't meant to be an example to demostrate how to build one. Hyperledger Composer will work with any Hyperledger Fabric setup with the right connection profiles anf Hyperledger Fabric provide documentation and examples on how to build your own networks which I think is what you need
See https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html
about how to build your own network and also see
https://hyperledger.github.io/composer/reference/connectionprofile.html
for information about composer connection profiles.
also see
Does composer support endorsement policy? How?
which provides some info about multi org networks and connection profiles

Resources