hyperledger fabric set ORDERER_CA using the bash - bash

I am writing the bash script to run hyperledger fabric setup with 2 organisation, and i am trying to install chain-code to. It works well in manual, but i have create the bash script, i am trying to export ORDERER_CA using below command. please suggest me.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp" -e "CORE_PEER_ADDRESS=peer0.org1.example.com:7051" -it cli export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
facing the error
OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: \"export\": executable file not found in $PATH": unknown

You cannot export the variable while the docker is running.
You should set the environment variable inside the docker-compose.yaml environments section and then run the docker with docker-compose.

Related

Docker Command Issue Running Outside of Bash

I have a Docker container that handles an application. I am attempting to write tests for my system using npx and nightwatchJS.
I use CI and to run the tests for my entire suite I docker-compose build then run commands from outside of the container like so:
Example of backend python test being called (this works and is run as expected):
docker-compose run --rm web sh -c "pytest apps/login/tests -s"
Now I am trying to run an npx command to do some front-end testing but I am getting errors with something I cannot seem to diagnose:
Error while running .navigateTo() protocol action: An unknown server-side error occurred while processing the command. – unknown error: net::ERR_CONNECTION_REFUSED
Here is that command:
docker-compose run --rm web sh -c "npx nightwatch apps/login/tests/nightwatch/login_test.js"
The odd part of this is that if I go into bash:
docker-compose exec web bash
And then run:
npx nightwatch apps/login/tests/nightwatch/login_test.js
I don't get that error as I'm in bash.
This leads me to believe that I have an error in something with the command. Can somebody please help with this?
Think as containers as a separate computers.
When you run on your computer pytest apps/login/tests -s and then I run on my computer npx nightwatch apps/login/tests/nightwatch/login_test.js surely my computer will not connect to yours. I will get "connection refused" kind of error.
With docker run you run a separate new "computer" that runs that command - it has it's own pid space, it's own network address, etc. Than inside "that computer" you can execute another command with docker exec. To have you command to connect with localhost, you have to run them on the same "computer".
So when you run docker run with the client, it does not connect to a separate docker run. Either specify correct ip address or run both commands inside the same container.
I suggest to research how docker works. The above is a very crude oversimplification.

starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown

e44671200b7c /# mysql -u root -p bash
mysql: command not found
I was able to enter into the container "mariadb" using
docker exec -it e44671200b7c /bin/bash
but i couldn't and i have this now error
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown
bash is not present in mariadb Docker image. Use docker exec -it e44671200b7c /bin/sh or simply docker exec -it e44671200b7c sh instead.
There are few images which do not support the interactive shell/bash. Example - Docker image mockserver/mockserver Docker Set Up
Docker Setup Page for MockServer

Problem running a docker container by specifying sh or bash for that image on a vm instance

I have vm environment which i have created using Microsoft azure cloud. I have installed docker in this vm. I can run docker image without specifying the any terminal like sh or bash and it is working. when i say
docker run -it hello-world --->> it works
docker run -it hello-world sh ---->>> it don't works.
actually i am working on a networking tool kathara where i have to start a virtual lab using many pcs and router and then i have to specify the terminal for them when i want to open any pc or router.
this is the actual error i am getting wheni start conatiner
"critical - 400 client error: bad request ("oci runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown")"
docker run -it hello-world runs the container's default command: ./hello. That works, because that's what the container is designed to do.
docker run -it hello-world /bin/bash tries to run /bin/bash inside the container. That doesn't work, because that's not what the container is designed to do. That command does not exist within the container.
If you want to run /bin/bash, choose a container that has /bin/bash.
This is even suggested in the output of docker run -it hello-world:
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

The input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'

This is related to question bash: C:/Program: No such file or directory
I am using Git Bash in Windows 10 and following the example/tutorial for Debezium for MSSQL Server that is found here: https://github.com/debezium/debezium-examples/blob/master/tutorial/README.md#using-sql-server
When I run the following command:
docker-compose -f docker-compose-sqlserver.yaml exec kafka /kafka/bin/kafka-console-consumer.sh \--bootstrap-server kafka:9092 \--from-beginning \--property print.key=true \--topic server1.dbo.customers
I get the following error:
the input device is not a TTY. If you are using mintty, try prefixing
the command with 'winpty'
When I type the following command:
winpty docker-compose -f docker-compose-sqlserver.yaml exec kafka /kafka/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --from-beginning --property print.key=true --topic server1.dbo.customers
I get the following error:
OCI runtime exec failed: exec failed: container_linux.go:349: starting
container process caused "exec: \"C:/Program
Files/Git/kafka/bin/kafka-console-consumer.sh\": stat C:/Program
Files/Git/kafka/bin/kafka-con sole-consumer.sh: no such file or
directory": unknown
Why is this happening and what is the fix?
UPDATE:
I am able to run the same command in Visual Studio Code's terminal window. The problem appears to be terminal specific. Can anyone expand on why the same command is treated differently across terminal environments?
Note: It would have been really helpful if the creator had provided and example for Windows 10 / Powershell users. I have posted a related question on what this script would like in Powershell v5.1 here: How to write the following script in Powershell

How to deploy web service on Docker container

This is my Dockerfile:
#Build java web app container image
FROM ubuntu
MAINTAINER wangyao
#Make java and tomcat install directory
RUN mkdir /usr/local/java
RUN mkdir /usr/local/tomcat
#Copy jre and tomcat into image
ADD jdk1.8.0_45.jdk /usr/local/java/
ADD apache-tomcat-7.0.62 /usr/local/tomcat/
ENV JAVA_HOME=/usr/local/java/Contents/Home
CMD cd /usr/local/tomcat;./bin/catalina.sh run
#Expose http port
EXPOSE 8080
Then i built it and try to start it:
wangyaos-MBP-3:flexcloud wangyao$ ls
Dockerfile apache-tomcat-7.0.62 jdk1.8.0_45.jdk
wangyaos-MBP-3:flexcloud wangyao$ docker build -t flexcloud .
Sending build context to Docker daemon 355.6 MB
Sending build context to Docker daemon
........
Successfully built 1f824d246b39
wangyaos-MBP-3:flexcloud wangyao$ docker run -i -t flexcloud
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/java/Contents/Home
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
/usr/local/java/Contents/Home/bin/java: 20: /usr/local/java/Contents/Home/bin/java: Syntax error: word unexpected (expecting ")")
wangyaos-MBP-3:flexcloud wangyao$
what does word unexpected (expecting ")") mean ?
I used $ ./bin/catalina.sh run without docker, and I can run it, but i why can not run it on the docker container ?
As indicated in the comments, the error Syntax error: word unexpected (expecting ")") is a shell script error, which implies that /usr/local/java/Contents/Home/bin/java is not actually the java executable.
Accessing the container with docker exec -it <container> bash and executing /usr/local/java/Contents/Home/bin/java -version shows us whats actually going on, as per #KingOfSocket's comment.

Resources