I have issues instantiating my chaincode on a channel (timeout), and as I'm quite new to Docker and containerisation it may come from network setup.
Here is the command:
docker exec -e "CORE_PEER_LOCALMSPID=ControlTowerMSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#controltower.com/msp" peer0.controltower.com peer chaincode instantiate -C frenchspoonchannel -n nodecc -v 1.0 -c '{"Args":["init","a","100","b","200"]}'
The chaincode container is created but not up and the command timeout
Peer logs:
2018-12-05 13:46:20.263 UTC [endorser] SimulateProposal -> ERRO 036 [frenchspoonchannel][b33ded8e] failed to invoke chaincode name:"lscc" , error: timeout expired while starting chaincode nodecc:1.0 for transaction b33ded8e61c100521c4e08ab9402b5324cb967f63e1163d1963e2293ce0445f6
dev-peer logs:
Error: Cannot find module '/usr/local/src/chaincode_example02.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chaincode_example02#1.0.0 start: `node chaincode_example02.js "-- peer.address" "192.168.176.5:7052"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chaincode_example02#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Orderer & Peer docker-compose.yaml
orderer.com:
container_name: orderer.com
image: hyperledger/fabric-orderer
environment:
- ORDERER_GENERAL_LOGLEVEL=info
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
command: orderer
ports:
- 7050:7050
volumes:
- ./config/:/etc/hyperledger/configtx
- ./crypto-config/ordererOrganizations/controltower.com/orderers/orderer.controltower.com/:/etc/hyperledger/msp/orderer
- ./crypto-config/peerOrganizations/controltower.com/peers/devpeer/:/etc/hyperledger/msp/peer0.controlTower.com
networks:
- controltower.com
peer0.controltower.com:
container_name: peer0.controltower.com
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.controltower.com
- CORE_LOGGING_PEER=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_LOCALMSPID=ControlTowerMSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer0.controltower.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=p0.controltower.co:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=p0.controltower.co:7051
#- CORE_PEER_CHAINCODELISTENADDRESS=peer0.controltower.com:7052
# # the following setting starts chaincode containers on the same
# # bridge network as the peers
# # https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_controltower.com
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
# The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
# provide the credentials for ledger to connect to CouchDB. The username and password must
# match the username and password set for the associated CouchDB.
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
# command: peer node start --peer-chaincodedev=true
ports:
- 7051:7051
#- 7052:7052
- 7053:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/controltower.com/peers/devpeer/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/controltower.com/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
- ./chaincode:/etc/hyperledger/chaincode
depends_on:
- orderer.com
- couchdb
networks:
- controltower.com
As you see I tried with the env var chaincode.listen.address and open new port 7052 but it didn't work.
Thanks !
Related
I am getting this issue on
`docker-compose up`
This is my configuration files:-
Dockerfile:
FROM python:3.9
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "uvicorn", "app.main:app","--host","0.0.0.0","--port","8000 " ]
docker-compose.yaml:
version: '3'
services:
api:
build: .
depends_on:
- postgres
ports:
- 8000:8000
volumes:
- ./:/usr/src/app:ro
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
# env_file:
# - ./.env
environment:
- DATABASE_HOST_NAME=postgres
- DATABASE_PORT=${DATABASE_PORT}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_USERNAME=${DATABASE_USERNAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
- SECRET_KEY=${SECRET_KEY}
- ALGORITHM=${ALGORITHM}
- ACCESS_TOKEN_EXPIRE_MINUTES=${ACCESS_TOKEN_EXPIRE_MINUTES}
postgres:
image: postgres
environment:
- POSTGRES_USER=${DATABASE_USERNAME}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
- POSTGRES_DB=${DATABASE_NAME}
volumes:
- postgres-db:/var/lib/postgresql/data
volumes:
postgres-db:
When i ran docker-compose build and docker-compose up -d these two commands ran succesfully but when i hit the login endpoint, it's giving the error
fastapi-api-1 | sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "postgres" (192.168.112.2), port 5432 failed: FATAL: password authentication failed for user "root"
My DATABASE_USERNAME is root
ERROR: for rca-org2 Cannot start service rca-org2: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.
I am getting this error when i try to run docker-compose file which looks like this :-
rca-org2:
container_name: rca-org2
image: hyperledger/fabric-ca:latest
command: /bin/bash -c 'fabric-ca-server start -d -b rca-org2-admin:rca-org2-adminpw --port 7055'
environment:
- FABRIC_CA_SERVER_HOME=/tmp/hyperledger/fabric-ca/crypto
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_CSR_CN=rca-org2
- FABRIC_CA_SERVER_CSR_HOSTS=0.0.0.0
- FABRIC_CA_SERVER_DEBUG=true
volumes:
- /tmp/hyperledger/org2/ca:/tmp/hyperledger/fabric-ca
networks:
- fabric-ca
ports:
- 7055:7055
-
After Research I found that the container rca-org2 doesn't have bash installed but it has sh so running the container with (replace /bin/bash with sh) worked for me. so now the new compose file looks like this.
rca-org2:
container_name: rca-org2
image: hyperledger/fabric-ca:latest
command: sh -c 'fabric-ca-server start -d -b rca-org2-admin:rca-org2-adminpw --port 7055'
environment:
- FABRIC_CA_SERVER_HOME=/tmp/hyperledger/fabric-ca/crypto
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_CSR_CN=rca-org2
- FABRIC_CA_SERVER_CSR_HOSTS=0.0.0.0
- FABRIC_CA_SERVER_DEBUG=true
volumes:
- /tmp/hyperledger/org2/ca:/tmp/hyperledger/fabric-ca
networks:
- fabric-ca
ports:
- 7055:7055
I have a service in the docker compose as follows.
nginx:
image: nginx:1.18.0-alpine
ports:
- 8000:80
volumes:
- ./nginx/localhost/conf.d:/etc/nginx/conf.d
- ./entrypoint.sh:/entrypoint.sh
entrypoint: ./entrypoint.sh
depends_on:
- webapp
networks:
- nginx_network
I get the error
Cannot start service nginx: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/entrypoint.sh": permission denied: unknown
ERROR: for nginx Cannot start service nginx: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/entrypoint.sh": permission denied: unknown
ERROR: Encountered errors while bringing up the project.
How can i do this
I have to use ["/bin/sh","/entrypoint.sh"]
nginx:
image: nginx:1.18.0-alpine
ports:
- 8000:80
volumes:
- ./nginx/localhost/conf.d:/etc/nginx/conf.d
- ./entrypoint.sh:/entrypoint.sh
entrypoint: ["/bin/sh","/entrypoint.sh"]
depends_on:
- webapp
networks:
- nginx_network
I don't have enough information about your entrypoint script, config file and the web app minimal information.
Sometimes when you create a file on your host machine it lacks some permissions to be executed by some users in your docker container, so Iwould think about checking the permissions for that file by running:
ls -l
that will give you all permissions about that file, and maybe that's why it's telling you permission is denied try adding execution permission running chmod +x ./entrypoint.sh.
I usually do that using a dockerfile when working on a script from my context.
dockerfile
FROM nginx:1.18.0-alpine
COPY /entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT [ "./entrypoint.sh" ]:
docker-compose.yaml
version: "3.8"
services:
nginx:
build:
context: ./
ports:
- 8000:80
volumes:
- ./nginx/localhost/conf.d:/etc/nginx/conf.d
depends_on:
- webapp
networks:
- nginx_network
Then try to run:
docker-compose up --build
make sure both files are in the same directory.
I created gitlab-ci.yml with docker and symfony for the first time. I learn.
I don't undertand whay it didn't work. I tried to change the name of the database. perhaps I forgot some things. I'm losing.
I need you for help to me.
Thanks you a lot
This is error
$ php bin/console doctrine:database:drop --if-exists --force -e test
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
In PDOConnection.php line 31:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
In PDOConnection.php line 27:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
In PDOConnection.php line 27:
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known
This is gitlab-ci file
default:
image: php:7.2-fpm
services:
- mysql:latest
cache:
paths:
- vendor/
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: sf4-reims
stages: # Ici on déclare toutes nos étapes
- build
- test
job:build:
stage: build
script:
- apt-get update
- curl -sSk https://getcomposer.org/installer | php -- --disable-tls &&
- mv composer.phar /usr/local/bin/composer
- composer install --prefer-dist
- echo $CI_JOB_STAGE
job:test:
stage: test
script:
- apt-get update
- apt-get install -y git zip zip unzip
- docker-php-ext-install pdo pdo_mysql
- cp .env.test .env
- php bin/console doctrine:database:drop --if-exists --force -e test
- bin/console doctrine:database:create --if-not-exists -e test
- bin/console doctrine:schema:drop --force --no-interaction -e test
- bin/console doctrine:schema:create --no-interaction -e test
- bin/console doctrine:fixtures:load --no-interaction --purge-with-truncate -vvv -e test
- echo $CI_JOB_STAGE
This is file .env
APP_ENV=test
DATABASE_URL=mysql://root:root#database:3306/sf4-reims
This is file docker-compose.yml
version: '3'
services:
apache:
container_name: ${CONTAINER_NAME}_apache
image: httpd:2.4.41
ports:
- ${APACHE_PORT}:80
- ${APACHE_PORT_SSL}:443
volumes:
- ./${DIRECTORY_PROJECT}:/var/www/html
- .docker/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf
- .docker/httpd/logs:/var/log/httpd
depends_on:
- php
networks:
- front-network
- back-network
database:
image: mysql
command: "--default-authentication-plugin=mysql_native_password"
container_name: ${CONTAINER_NAME}_database
volumes:
- .docker/data/db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
networks:
- back-network
php:
build: .docker/php
container_name: ${CONTAINER_NAME}_php
volumes:
- ./${DIRECTORY_PROJECT}:/var/www/html
- .docker/php/php.ini:/usr/local/etc/php/php.ini
environment:
- maildev_host=${CONTAINER_NAME}_maildev
depends_on:
# - maildev
- database
networks:
- back-network
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: ${CONTAINER_NAME}_phpmyadmin
environment:
PMA_HOST: database
PMA_PORT: ${MYSQL_PORT}
ports:
- ${PHPMYADMIN_PORT}:80
links:
- database
networks:
- back-network
I know this was posted 9 months ago, but I believe I've just encountered the same problem, but could get it working by adding alias to the mysql service in the gitlab-ci.yml.
I can see you "index" your mysql container database in the docker-compose.yml, so I believe your application references the mysql host as database in your application configuration (config/packages/doctrine.yaml doctrine.dbal.host). In this case, you should write
default:
image: php:7.2-fpm
services:
- name: mysql:latest
alias: database
instead of
default:
image: php:7.2-fpm
services:
- mysql:latest
in your gitlab-ci.yml. In case you use another name in your host settings, then you should use that as an alias.
I'm working with docker image that uses Python3.6 as its base. All of the sudden it started crashing (exiting right after start up). So I bashed into the container and found out that
it crashes because connection to containerized postgres database fails all of the sudden.
The only error output I managed to get is forward host lookup failed: Unknown host which isn't telling me much.
entrypoint.sh:
echo "Waiting for postgres..."
while ! nc -z users-db 5432; do
sleep 0.1
done
echo "PostgreSQL started"
python manage.py run -h 0.0.0.0
error output:
Waiting for postgres...
users-db: forward host lookup failed: Unknown host
users-db: forward host lookup failed: Unknown host
users-db: forward host lookup failed: Unknown host
...
...
Dockerfile:
FROM python:3.6.9-slim
LABEL maintainer="abc"
RUN apt-get update && \
apt-get install -y netcat && \
apt-get clean
WORKDIR /usr/src/app
COPY ./requirements.txt /usr/src/app/requirements.txt
RUN pip install -r requirements.txt
COPY ./entrypoint.sh /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh
COPY . /usr/src/app
CMD ["/usr/src/app/entrypoint.sh"]
What strikes me about this is that it worked wonderfully until now and without me making any changes to the database container the connection failed.
What can I do to troubleshoot this ? If you need to review any files just ask and I'll share it here.
docker ps:
72d344cc61bf tdd_nginx "nginx -g 'daemon of…" 25 minutes ago Restarting (1) 55 seconds ago tdd_nginx_1
8ee2f8082e69 tdd_client "npm start" 26 minutes ago Up 25 minutes 0.0.0.0:3007->3000/tcp tdd_client_1
1ccfc3ca5600 tdd_users-db "docker-entrypoint.s…" 26 minutes ago Up 26 minutes 0.0.0.0:5435->5432/tcp tdd_users-db_1
--> 62af29277b78 tdd_users "/bin/bash -s" 22 minutes ago Exited (130) 2 minutes ago # <-- keeps crashing
docker-compose file:
version: '3.7'
services:
users:
build:
context: ./services/users
dockerfile: Dockerfile
volumes:
- './services/users:/usr/src/app'
ports:
- 5001:5000
environment:
- FLASK_ENV=development
- APP_SETTINGS=project.config.DevelopmentConfig
- DATABASE_URL=postgres://postgres:postgres#users-db:5432/users_dev
- DATABASE_TEST_URL=postgres://postgres:postgres#users-db:5432/users_test
- SECRET_KEY=bart_simpson
depends_on:
- users-db
client:
build:
context: ./services/client
dockerfile: Dockerfile
volumes:
- './services/client:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- 3007:3000
environment:
- NODE_ENV=development
- REACT_APP_USERS_SERVICE_URL=${REACT_APP_USERS_SERVICE_URL}
depends_on:
- users
nginx:
build:
context: ./services/nginx
dockerfile: Dockerfile
restart: always
ports:
- 80:80
depends_on:
- users
- client
users-db:
build:
context: './services/users/project/db'
dockerfile: Dockerfile
ports:
- 5435:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
Problem was that I've got pyjwt library installed for generating web tokens and I used pyjwt.encode() instead of jwt.encode() in my code. That made a major difference to the functionality of the connection between containers. Still don't know why though. Containers are now running again. If somebody will vote to close this topic I'll understand as nobody would've guessed this.