Docker - laradoc couldn't get logged in phpmyadmin - php

I have installed laradoc as per documentation but I am unable to login phpmyadmin.
here is my docker-compose.yaml file:
phpmyadmin:
build: ./phpmyadmin
environment:
- PMA_ARBITRARY=1
- MYSQL_USER=${PMA_USER}
- MYSQL_PASSWORD=${PMA_PASSWORD}
- MYSQL_ROOT_PASSWORD=${PMA_ROOT_PASSWORD}
ports:
- "${PMA_PORT}:80"
depends_on:
- "${PMA_DB_ENGINE}"
networks:
- frontend
- backend
and here is .env file
PMA_DB_ENGINE=mysql
PMA_USER=default
PMA_PASSWORD=secret
PMA_ROOT_PASSWORD=secret
PMA_PORT=8080

Difficult to reproduce the error from the given info but this small setup works so maybe you can find what went wrong?
First bring your existing stack down and delete dangling volumes:
$ docker-compose down
$ docker volume prune
Start the following docker-compose.yaml:
version: '3.1'
services:
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
- PMA_ARBITRARY=1
- MYSQL_USER=${PMA_USER}
- MYSQL_PASSWORD=${PMA_PASSWORD}
- MYSQL_ROOT_PASSWORD=${PMA_ROOT_PASSWORD}
ports:
- "${PMA_PORT}:80"
depends_on:
- "${PMA_DB_ENGINE}"
networks:
- frontend
- backend
mysql:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: db
MYSQL_USER: default
MYSQL_PASSWORD: secret
networks:
- frontend
- backend
networks:
frontend:
backend:
info (I had to use mysql5.7 otherwise I was facing this bug:
docker-compose up -d
Creating network "test_frontend" with the default driver
Creating network "test_backend" with the default driver
Creating test_mysql_1 ... done
Creating test_phpmyadmin_1 ... done
I know I'm a bit 'messing' with the syntax + you can use the env vars too for mysql but I had to be quick.

Related

MacOs - localhost file not found 404

Can someone please help.
I was running successfully my Symfony project via Docker containers. Suddenly when I access http://localhost/ I get the File not found. error?
I now that it means that system can not locate my files, but I am not sure what happened.
I see that my containers are built and running okay.
Also the same message I get when I try to test app endpoints through Postman.
I am on Mac Monterey 12.4.
Everything was working fine couple of hours ago. I just switched branches to change something, then switched back. The problem was on both branches..
Can someone help, I do not know what to do?
Docker config:
services:
db:
image: postgres:${POSTGRES_VERSION:-12}-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-name}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-pass}
POSTGRES_USER: ${POSTGRES_USER:-postgres}
volumes:
- $PWD/postgres-data:/var/lib/postgresql/data:rw
profiles:
- db-in-docker
ports:
- "5432:5432"
networks:
- symfony
redis:
image: "redis:alpine"
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "6379:6379"
volumes:
- $PWD/redis-data:/var/lib/redis
- $PWD/redis/redis.conf:/usr/local/etc/redis/redis.conf
environment:
- REDIS_REPLICATION_MODE=master
networks:
- symfony
php:
container_name: "backend_php"
build:
context: ..
dockerfile: docker/php/Dockerfile
target: dev
args:
TIMEZONE: ${TIMEZONE}
volumes:
- symfony_docker_app_sync:/var/www/symfony/
depends_on:
- redis
networks:
- symfony
nginx:
build:
context: ./nginx
volumes:
- ../:/var/www/symfony/
ports:
- 80:80
depends_on:
- php
networks:
- symfony
env_file:
- .env.nginx.local
First of all: Why do you donĀ“t use the built in symfony server for local development? However - how looks your docker container configuration for your webserver?

Docker compose: getaddrinfo for mariadb failed

I'm quite bad at creating docker-compose and I currently have a problem when I try to build a new project.
After the build I can't access my mariadb server within my php app container, I've got this error:
PDO::__construct(): php_network_getaddresses: getaddrinfo for mariadb
failed: Name does not resolve
So I know something is misconfigured but I don't know what, yet. I tried many changes but nothing that worked.
Here is my current docker-compose.yml:
version: "3.8"
networks:
# used by some services (php) to communicate with other docker-compose.yaml
censored.com:
external:
name: censored.com
services:
app:
build:
context: .
target: symfony_php
args:
- secret=id=composerauth,src=${HOME}/.composer/auth.json
restart: unless-stopped
healthcheck:
interval: 10s
timeout: 3s
retries: 3
start_period: 30s
environment:
APP_ENV: dev
HOST: www.censored.lan
networks:
- default
- censored.com
volumes:
- ./:/srv/app:rw,cached
- ./docker/php/conf.d/symfony.dev.ini:/usr/local/etc/php/conf.d/symfony.ini
- ${HOME}/.composer/auth.json:/root/.composer/auth.json
# If you develop on Linux, comment out the following volumes to just use bind-mounted project directory from host
- ./var/cache:/srv/app/cache:rw
- ./var/log:/srv/app/logs:rw
depends_on:
- mariadb
extra_hosts:
- www.censored.lan:127.0.0.1
nginx:
build:
context: .
target: symfony_nginx
args:
- secret=id=composerauth,src=${HOME}/.composer/auth.json
restart: unless-stopped
depends_on:
- app
environment:
NGINX_DOMAIN: www.censored.lan
ports:
- 8001:80
volumes:
- ./docker/nginx/templates/dev.conf.template:/etc/nginx/templates/default.conf.template:ro
- ./docker/nginx/rules/rules.dev.conf:/etc/nginx/rules.conf:ro
- ./public:/srv/app/public:ro
- ./src:/srv/app/src:ro
mariadb:
image: mariadb:10.7
environment:
MYSQL_ROOT_PASSWORD: changeme
MYSQL_DATABASE: database
MYSQL_USER: user
MYSQL_PASSWORD: changeme
networks:
- default
- censored.com
ports:
- '3307:3306'
restart: on-failure
volumes:
- db_data:/var/lib/mysql
volumes:
db_data: {}
Can someone help me to fix the issue please?
Thanks !
The problem wasn't related to my docker-compose configuration file.
My app is a PHP Symfony app and it was doing a "cache:clear" after the initial "composer install" during the build. The "cache:clear" was triggering calls to the database which wasn't ready yet.
To solve this I just had to set my mariadb version to my "DATABASE_URL" parameter in my Symfony app, to avoid useless database queries.

How to set prestashop database server from docker-compose?

I'm moving my prestashop installation to docker containers. I have a container with prestashop, mariadb and phpmyadmin on Ubuntu. I've set the environment variables as suggested here: https://githubmemory.com/repo/PrestaShop/docker. Here is my docker-compose:
version: "2"
services:
prestashop:
image: prestashop/prestashop
networks:
mycustomnetwork:
ports:
- 82:80
links:
- mariadb:mariadb
depends_on:
- mariadb
volumes:
- ./src:/var/www/html
- ./src/modules:/var/www/html/modules
- ./src/themes:/var/www/html/themes
- ./src/override:/var/www/html/override
environment:
- PS_DEV_MODE=1
- DB_SERVER=mariadb
- DB_USER=user_8
- DB_PASSWD=password_8
- DB_NAME=db_8
- PS_INSTALL_AUTO=0
mariadb:
image: mariadb
networks:
mycustomnetwork:
volumes:
- db_data:/docker-entrypoint-initdb.d
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=db_8
- MYSQL_USER=user_8
- MYSQL_PASSWORD=password_8
phpmyadmin:
image: phpmyadmin/phpmyadmin
networks:
mycustomnetwork:
links:
- mariadb:mariadb
ports:
- 1235:80
depends_on:
- mariadb
environment:
- PMA_HOST=mariadb
- PMA_USER=user_8
- PMA_PASSWORD=password_8
volumes:
db_data:
networks:
mycustomnetwork:
The database works, I can connect to it via phpmyadmin. However in the prestashop logs I get this error:
Link to database cannot be established: SQLSTATE[HY000] [2002] No such file or directory at line 127 in file classes/db/DbPDO.php
I modified the code, which threw this error so it prints the variables it uses to try to establish the connection ($this->server, $this->user, $this->password, $this->database) and I got this: localhost user password db. These values are from app/config/parameters.php and not the environment variables I set in the docker-compose. What should I do so it uses the values I provided in docker-compose instead of the ones from parameters.php?
I think Prestashop is reading app/config/parameters.phhp file before parsing env vars.
To bypass this, you should force PShop to read conf from env vars.
Use getenv(<ENV_NAME>)
'database_host' => getenv('DB_SERVER')

Dockerization PHP-APACHE MYSQL on centos7

i have tried creating a docker container on centos7 but
i could access phpmyadmin page but not index.php page
could you see the docker yml and docker file and tell what happened
like im running through kali linux to a centos7 docker its been difficult i have been trying since yesterday
the give code is docker-compose.yml
version: "3"
services:
www:
build: .
ports:
- "8001:80"
volumes:
- ./www:/var/www/html/
links:
- db
networks:
- default
db:
image: mysql:8.0.16
command: ['--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci','--default-authentication-plugin=mysql_native_password']
ports:
- "8002:3306"
environment:
MYSQL_DATABASE: myDb
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test
volumes:
- ./dump:/docker-entrypoint-initdb.d
- persistent:/var/lib/mysql
networks:
- default
phpmyadmin:
image: phpmyadmin/phpmyadmin:4.9
links:
- db:db
ports:
- 8000:80
environment:
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test
volumes:
persistent:
and the dockerfile
FROM php:7.1.19-apache
RUN docker-php-ext-install mysqli mbstring
i dont know what is the issue like when access localhost:8000 on browser
im getting forbidden access 403 error
i just need to access index.php when i enter localhost:8000 on browser
please help me out,
thank you in advance

connect a password of mssql server to other services in using docker

Hello there I am practicing Docker and Docker-compose. It is quite fun and cool.
I am a beginner also. I am trying to make a docker-compose.yml file for creating 3 services ( I dont know if this is the right term for it) the services are follows:
frontend
backend
database
Here is my code
docker-compose.yml
frontend:
image: eboraas/apache-php
build: ./dockerfile-frontend
links:
- database
environment:
- WORDPRESS_DB_PASSWORD=embuscado29
ports:
- "<server public IP>:8082:8082"
volumes:
- ./code:/code
- ./html:/var/www/html
backend:
image: eboraas/apache-php
build: ./dockerfile-frontend
links:
- database
environment:
- WORDPRESS_DB_PASSWORD=embuscado29
ports:
- "<server public IP>:8082:8082"
volumes:
- ./code:/code
- ./html:/var/www/html
database:
image: mariadb
environment:
volumes:
- ./database:/var/lib/mysql
My question how can I connect the frontend and backend services to the database service? my database will be a mssql server
you do not need to separate frontend and backend, especially if both have the same image. You also should specify image or build, not both. For database, all your environmental variables go to environment. Using mssql is not a very bright idea, but if you wish...
This is how I would have done it:
version: "2"
web:
image: php:5-apache
links:
- database
environment:
- WORDPRESS_DB_PASSWORD=embuscado29
ports:
- "<server public IP>:8082:8082"
volumes:
- ./code:/code
- ./html:/var/www/html
mssql:
image: rsmoorthy:mssql
environment:
- MSSQL_DB_HOST: mssql
- MSSQL_DB_PORT: 1433
- MSSQL_DB_USER: sa
- MSSQL_DB_PASSWORD: hello
- MSSQL_DB_DATABASE: test

Categories