ERROR: for rca-org2 Cannot start service rca-org2: OCI runtime create failed: container_linux.go:345: - docker-compose

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

Related

fastapi & psycopg2 : password authentication failed for user "root"

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

docker compose how to mount entrypoint and then use it

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.

Gitlab-ci wit symfony : php_network_getaddresses: getaddrinfo failed: Name or service not known

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.

OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"mysql\":

I'm getting:
"OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"mysql\": executable file not found in $PATH": unknown" while passing below command
docker exec -i postgres postgres-u root -pmypassword mysql < db/cicd/build-artifacts/testreport/database.sql
My docker-compose.yml file:
version: '3.3'
services:
postgres:
image: mysql:5.7.10
container_name: postgres
ports:
- 3306
healthcheck:
test: postgres --user=root --password=mypassword -e 'select version()'
timeout: 1s
retries: 5
environment:
postgres_ROOT_PASSWORD: mypassword
postgres_USER: root
postgres_DATABASE: Dev
volumes:
- ./build-artifacts:/scripts
command: --postgres_mode=""
dbfit:
container_name: dbfit
image: mattthinkwhere/dbfit
ports:
- 8085:8085
volumes:
- ./build-artifacts/dbfit_tests:/dbfit/FitNesseRoot/TestSuite
- ./build-artifacts:/scripts
links:
- postgres
depends_on:
- postgres
I think you used the wrong container ID. The message says he doesn't know the command "mysql" inside the container.

Postgres in docker-compose can't find/mount /etc/postgresql/postgres.conf

I'm trying to mount my postgres.conf and pg_hba.conf using docker-compose and having difficulty understanding why it work when run using docker-cli and doesn't with docker-compose
The following docker-compose causes the image to crash with error:
/usr/local/bin/docker-entrypoint.sh: line 176: /config_file=/etc/postgresql/postgres.conf: No such file or directory
docker-compose.yml
services:
postgres-master:
image: postgres:11.4
container_name: postgres-master
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
- /home/agilob/dockers/pg/data:/var/lib/postgresql/data:rw
- $PWD/pg:/etc/postgresql:rw
- /etc/localtime:/etc/localtime:ro
hostname: 'primary'
environment:
- PGHOST=/tmp
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
- MAX_CONNECTIONS=10
- MAX_WAL_SENDERS=5
- PG_MODE=primary
- PUID=1000
- PGID=1000
ports:
- "5432:5432"
command: 'config_file=/etc/postgresql/postgres.conf hba_file=/etc/postgresql/pg_hba.conf'
This command works fine:
docker run -d --name some-postgres -v "$PWD/postgres.conf":/etc/postgresql/postgresql.conf postgres -c 'config_file=/etc/postgresql/postgresql.conf'
also when I remove command: section and run the same docker-compose:
$ docker-compose -f postgres-compose.yml up -d
Recreating postgres-master ... done
$ docker exec -it postgres-master bash
root#primary:/# cd /etc/postgresql
root#primary:/etc/postgresql# ls
pg_hba.conf postgres.conf
The files are present in /etc/postgres.
Files in $PWD/pg are present:
$ ls pg
pg_hba.conf postgres.conf
The following works fine:
command: postgres -c config_file='/etc/postgresql/postgres.conf' -c 'hba_file=/etc/postgresql/pg_hba.conf'