Chaincode setup Hyperledger Fabric - blockchain

I'm trying to setup Hyperledger Fabric chaincode development setup in my MAC machine. I already have the development environment setup, but my end goal is to just develop a blockchain application on top of Hyperledger Fabric. So I am moving towards the docker chaincode developement and test environment. I'm following the instructions given here (following the Option 2). The docker-compose up command is throwing the following error :
himanshus-mbp:fabric himanshutyagi$ docker-compose up
Recreating fabric_membersrvc_1
Creating fabric_vp_1
ERROR: for vp driver failed programming external connectivity on endpoint fabric_vp_1 (98887f3aa674ed269b3bf9cae87f28d7686920343a9cb2aac5f2715b1a945da8): Error starting userland proxy: write /port/tcp:0.0.0.0:5000:tcp:172.17.0.2:5000/ctl: errno 526
ERROR: Encountered errors while bringing up the project.
There is nothing related to this on the github issues. Can anyone explain what might be going wrong ?

If you know what process is running at port 5000 then try with sudo lsof -i tcp:5000 then note the process id and run sudo kill -15 <PROCESS_ID_HERE>. After that retry running docker commad

The port is probably already in use by another process. Has it already been started or is another program using the port. Use lsof to help find the process.

Related

How can I use kubernetes cluster in Windows WSL2?

I am trying to create cluster by using this article in my WSl Ubuntu. But It returns some errors.
Errors:
yusuf#DESKTOP-QK5VI8R:~/aws/kubs2$ sudo systemctl daemon-reload
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
yusuf#DESKTOP-QK5VI8R:~/aws/kubs2$ sudo systemctl restart kubelet
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
yusuf#DESKTOP-QK5VI8R:~/aws/kubs2$ sudo kubeadm init --pod-network-cidr=10.244.0.0/16
[init] Using Kubernetes version: v1.21.1
[preflight] Running pre-flight checks
[WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR Port-6443]: Port 6443 is in use
[ERROR Service-Docker]: docker service is not active, please run 'systemctl start docker.service'
[ERROR Swap]: running with swap on is not supported. Please disable swap
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
I don't understand the reason when I use sudo systemctl restart kubelet. Error like this occurs:
docker service is not enabled, please run 'systemctl enable docker.service'
When I use:
yusuf#DESKTOP-QK5VI8R:~/aws/kubs2$ systemctl enable docker.service
Failed to enable unit, unit docker.service does not exist.
But I have docker images still runnig:
What is wrong while creating Cluster Kubernetes in WSL? Is there any good tutorial for creating cluster in WSL?
Tutorial you're following is designed for cloud Virtual machines with Linux OS on them (this is important since WSL works a bit differently).
E.g. SystemD is not presented in WSL, behaviour you're facing is currently in development phase.
What you need is to follow designated tutorial for WSL (WSL2 in this case). Also see that docker is set up on Windows machine and shares its features with WSL integration. Please find Kubernetes on Windows desktop tutorial (this uses KinD or minikube which is enough for development and testing)
Also there's a part for enabling SystemD which can potentially resolve your issue on a state where you are (I didn't test this as I don't have a windows machine).

Laravel application doesn't start on PORT number on Cloud Run

I deployed my app on Cloud Run service of google. It shows error "Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.
". I run this image on Cloud Shell to test, it still runs with PORT 8080 and bind 0.0.0.0, I can not find more error in log of cloud run. My project is laravel project. Please help me, how to find out more logs and debug this case.
Check Image
Port running
I fixed it. When i run with supervisor at local it runs, but on Cloud Run it's not ok. So i've changed to entrypoint to start php-fpm and nginx, it's okie on Cloud Run
You can look at this step by step guide that might help for this or similar problems with Laravel and Google Cloud Run.

Connecting Hyperledger Composer to Fabric: Error trying install composer runtime

While following the tutorial on this link, I encontered the following error under the section "Deploy to the running Hyperledger Fabric". My Hyperledger Fabric is not running and I do not know why. The error I get is shown below:
tom#tom:~/hyperledger/my-network/dist$ composer network deploy -a my-network.bna -p hlfv1 -i PeerAdmin -s randomString
Deploying business network from archive: my-network.bna
Business network definition:
Identifier: my-network#0.1.6
Description: My Commodity Trading network
✖ Deploying business network definition. This may take a minute...
Error: Error trying deploy. Error: Error trying install composer runtime. Error: Connect Failed
Command failed
When I use docker ps -a, no hyperledger containers are shown to have run. Where could I have gone wrong?
I just realized I needed to install docker-compose which deals with running multiple docker containers instead of just using docker client.
For docker-compose installation, I consulted the manual
I think you did not start your fabric, if you are developing locally. Please look at https://hyperledger.github.io/composer/installing/development-tools.html for the environment setup and the scripts you need to run inorder to have a local fabric.
When you run docker ps you should see something like this docker list of containers

Setup Hyperledger Fabric

I try to setup the Hyperledger Fabric project. Unfortunately, when I invoke vargant up I get:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'hyperledger/fabric-baseimage' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: 0.0.10
The box 'hyperledger/fabric-baseimage' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://atlas.hashicorp.com/hyperledger/fabric-baseimage"]
Error: SSL certificate problem: unable to get local issuer certificate
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
I tried to use docker image https://hub.docker.com/r/hyperledger/fabric-baseimage/ but run command didn't do anything
I would like to start Fabric Blockchain, try management system, deploy contract and initiate some test transactions. Could anyone help me, how to start Fabric?
Thanks
The error listed here is pretty clear and provides a link to the resolution. Vagrant is unable to download the image because the local CA did not carry the certificate of the CA that issued the HashiCorp server's certificate.
If you are interested in simply running the Hyperledger Fabric and developing/deploying chaincode and developing a blockchain application, you can simply run docker-compose up with the following docker-compose.yml definition using Docker for Mac or Windows (beta):
vp:
image: hyperledger/fabric-peer
ports:
- "5000:5000"
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=http://127.0.0.1:2375
- CORE_LOGGING_LEVEL=DEBUG
command: peer node start
membersrvc:
image: hyperledger/fabric-membersrvc
command: membersrvc
The Vagrant-based development environment approach to getting the Fabric running on your laptop is really more oriented towards developers wishing to help with the development OF the Hyperledger Fabric project than it is for those who simply wish to develop applications using the platform.
I recommend you to install again.
vagrant destroy. It will stops and deletes all traces of the vagrant machine.
vagrant up. starts and provisions the vagrant environment.
Try these instructions:
http://hyperledger-fabric.readthedocs.io/en/latest/dev-setup/devenv.html
I used branch v0.6 of the hyperledger fabric from GitHub instead of
the Gerrit one (at step "Cloning the Fabric project"):
git clone -b v0.6 https://github.com/hyperledger/fabric.git
When the VM provisioning will be complete at the end, you will have an environment ready to be used for testing chaincode.
When the environment is complete, you should also check out the GitHub IBM-Blockchain marbles app.
Hope this works out for you, good luck.
Open this link: https://atlas.hashicorp.com/hyperledger/boxes/fabric-baseimage
Use command below:
vagrant init hyperledger/fabric-baseimage; vagrant up --provider virtualbox

Hyperledger fabric behave tests failing "cannot connect to Docker endpoint"

Using Hyperledger fabric, I run make behave-deps then make behave, yet several of the behave test scenarios fail ("Error starting container: cannot connect to Docker endpoint") - how would I go about fixing this?
Typically this problem is encountered when running outside of Vagrant.
Ensure you can run
docker run hello-world
Without sudo
If this fails, this can be resolved by adding he user to the group as in the installation docs
If running the vagrant-based development environment described here, a change was recently made to the Docker port mapping that would manifest itself with these failed tests. Reconstruct your development environment with vagrant destroy and vagrant up from the $GOPATH/src/github.com/hyperledger/fabric/devenv directory.