Docker phpmyadmin after login: 504 Gateway Time-out - mysql

Trying to use docker phpmyadmin to connect several different mysql's both local (containers) and remote servers. All works fine till I start to log in - connecting to remote server works like a charm, problem is to connect local server's containers.
My conf for compose looks like this:
version: '3'
services:
phpmyadmin:
image: phpmyadmin_4.7.6
container_name: phpmyadmin
restart: always
ports:
- "8081:80"
volumes:
- "./conf_phpmyadmin/:/root/confs/"
- "/sessions"
networks:
proxy:
ipv4_address: "172.18.0.4"
environment:
- PMA_ABSOLUTE_URI=https://<access-url>/phpmyadmin/
- PMA_HOSTS=172.21.0.3,192.168.1.65
- PMA_VERBOSES=LocalMysqlContainer,RemoteMySql
links:
- mysql-5.7:mysql
php7:
restart: always
image: php7-phalcon
hostname: <hostname>
container_name: <container name>
expose:
- 82
# add static IP in case of restart
networks:
network1:
ipv4_address: "172.21.0.2"
proxy:
environment:
- VIRTUAL_HOST=${VIRTUAL_HOST}
- LETSENCRYPT_HOST=${VIRTUAL_HOST}
- LETSENCRYPT_EMAIL=${EMAIL}
mysql-5.7:
restart: always
image: prod-mysql
container_name: mysql
# add static IP in case of restart
networks:
network1:
ipv4_address: "172.21.0.3"
volumes:
- "/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}
# create custom network
networks:
proxy:
external:
name: webproxy_proxy
network1:
driver: bridge
ipam:
config:
- subnet: "172.21.0.0/24"
Tried to add mysql container to same network as nginx proxy is (same subnet as phpmyadmin is).
Tried different ports and IP-s and variations.
Using:
docker-compose version 1.17.1, build 6d101fb
docker-py version: 2.5.1
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t 3 May 2016
Docker itself:
Client:
Version: 17.09.0-ce
API version: 1.32
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:42:18 2017
OS/Arch: linux/amd64
Server:
Version: 17.09.0-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:40:56 2017
OS/Arch: linux/amd64
Experimental: false

Okei, figured it out myself.
Found solution with that help: https://www.dgendill.com/posts/programming/2016-07-03-docker-mysql-notes.html
Not sure though, what exactly helped, but ..

Related

ERROR 2002 (HY000): Can't connect to MySQL server on 'db' (115)

I am trying to move existing project to Docker. I followed this tutorial at M.Academy and followed the setup instructions from Docker on Existing Project
While executing trying to connect with MySQL I am getting this error ERROR 2002 (HY000): Can't connect to MySQL server on 'db' (115)
I also tried to execute: telnet db 3306
Response:
Trying 172.17.0.1...
telnet: Unable to connect to remote host: Connection timed out
I tried everything but couldn't figure out the problem. I am new to Docker. I am using Ubuntu 18.04 LTE. Haven't changed db.env and got no error on any other step before importing the database.
I further checked and found out that the container is not able to establish connection with MySQL.
P.S. I am successfully able to connect with same MySQL service outside Docker container by using (external MySQL port) mysql -h 127.0.01 -u root -p -P 3306
Steps To Reproduce
Install Docker & Docker Compose on Ubuntu 18.04
Download the Docker Compose template: curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/template | bash
Replace with existing source code of your existing Magento instance: cp -R ~/Sites/existing src
Execute: docker-compose -f docker-compose.yml up -d
Copy files to container: bin/copytocontainer --all
Import existing database: bin/mysql < /var/www/magento243.sql
Expected Result
Database should have been successfully imported
Actual Result
ERROR 2002 (HY000): Can't connect to MySQL server on 'db' (115)
P.S. Issue has already been raised here: https://github.com/markshust/docker-magento/issues/589
docker-compose.yml
version: "3"
services:
app:
image: markoshust/magento-nginx:1.18-5
ports:
- "80:8000"
- "443:8443"
depends_on:
- "db"
volumes: &appvolumes
- ~/.composer:/var/www/.composer:cached
- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
- ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached
- appdata:/var/www/html
- sockdata:/sock
- ssldata:/etc/nginx/certs
extra_hosts: &appextrahosts
## M1 Mac support to fix Docker delay, see #566
- "app:172.17.0.1"
- "phpfpm:172.17.0.1"
- "db:172.17.0.1"
- "redis:172.17.0.1"
- "elasticsearch:172.17.0.1"
- "rabbitmq:172.17.0.1"
## Selenium support, replace "magento.test" with URL of your site
- "magento.test:172.17.0.1"
phpfpm:
image: markoshust/magento-php:7.4-fpm-11
volumes: *appvolumes
extra_hosts: *appextrahosts
env_file: env/phpfpm.env
db:
image: mariadb:10.4
command: --max_allowed_packet=256M
ports:
- "3306:3306"
env_file: env/db.env
volumes:
- dbdata:/var/lib/mysql
extra_hosts: *appextrahosts
redis:
image: redis:5.0-alpine
ports:
- "6379:6379"
extra_hosts: *appextrahosts
elasticsearch:
image: markoshust/magento-elasticsearch:7.9.3-1
ports:
- "9200:9200"
- "9300:9300"
environment:
- "discovery.type=single-node"
## Set custom heap size to avoid memory errors
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
## Avoid test failures due to small disks
## More info at https://github.com/markshust/docker-magento/issues/488
- "cluster.routing.allocation.disk.threshold_enabled=false"
- "index.blocks.read_only_allow_delete"
extra_hosts: *appextrahosts
rabbitmq:
image: rabbitmq:3.8.22-management-alpine
ports:
- "15672:15672"
- "5672:5672"
volumes:
- rabbitmqdata:/var/lib/rabbitmq
environment:
- RABBITMQ_VM_MEMORY_HIGH_WATERMARK=1GB
extra_hosts: *appextrahosts
mailcatcher:
image: sj26/mailcatcher
ports:
- "1080:1080"
extra_hosts: *appextrahosts
## Selenium support, uncomment to enable
#selenium:
# image: selenium/standalone-chrome-debug:3.8.1
# ports:
# - "5900:5900"
# extra_hosts: *appextrahosts
volumes:
appdata:
dbdata:
rabbitmqdata:
sockdata:
ssldata:
This issue was finally resolved by
Removing extra_hosts entries from the YML file
Adding networks in YML
Final docker-compose.yml
version: "3"
services:
app:
image: markoshust/magento-nginx:1.18-5
ports:
- "81:8000"
- "444:8443"
depends_on:
- "db"
volumes: &appvolumes
- ~/.composer:/var/www/.composer:cached
- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
- ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached
- appdata:/var/www/html
- sockdata:/sock
- ssldata:/etc/nginx/certs
networks:
- customNetwork
phpfpm:
image: markoshust/magento-php:7.4-fpm-11
volumes: *appvolumes
env_file: env/phpfpm.env
networks:
- customNetwork
db:
image: mariadb:10.4
command: --max_allowed_packet=256M
ports:
- "3307:3306"
env_file: env/db.env
volumes:
- dbdata:/var/lib/mysql
networks:
- customNetwork
redis:
image: redis:5.0-alpine
ports:
- "6379:6379"
networks:
- customNetwork
elasticsearch:
image: markoshust/magento-elasticsearch:7.9.3-1
ports:
- "9201:9200"
- "9301:9300"
environment:
- "discovery.type=single-node"
## Set custom heap size to avoid memory errors
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
## Avoid test failures due to small disks
## More info at https://github.com/markshust/docker-magento/issues/488
- "cluster.routing.allocation.disk.threshold_enabled=false"
- "index.blocks.read_only_allow_delete"
networks:
- customNetwork
rabbitmq:
image: rabbitmq:3.8.22-management-alpine
ports:
- "15672:15672"
- "5672:5672"
volumes:
- rabbitmqdata:/var/lib/rabbitmq
environment:
- RABBITMQ_VM_MEMORY_HIGH_WATERMARK=1GB
networks:
- customNetwork
mailcatcher:
image: sj26/mailcatcher
ports:
- "1080:1080"
networks:
- customNetwork
volumes:
appdata:
dbdata:
rabbitmqdata:
sockdata:
ssldata:
networks:
customNetwork:

How to establish connection between Web & Database (windows base) docker container , running through docker-compose file?

Docker engine is running on AWS windows server 2016
Here is docker-compose.yml file
version: '3'
services:
controllerdb:
hostname: controllerdb
image: <windows base mysql image>
restart: always
web:
hostname: web
depends_on:
- controllerdb
image: <windows base tomcat image>
restart: always
ports:
- 8080:8080
links:
- controllerdb
networks:
default:
external:
name: nat
For connecting with database URL in tomcat
URL = jdbc:mysql://controllerdb:3306/database_name"
But on running compose file its giving error
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not
received any packets from the server.
**Caused by: java.net.UnknownHostException: controllerdb**
Even after providing correct hostname , its giving UnknownHostException.
This connection work with linux container but I want to establish it in windows container.
Please , let me know how to fix it, So that inter container communication in windows containers can be done.
version: '3'
services:
controllerdb:
hostname: controllerdb
image: <windows base mysql image>
restart: always
networks:
- app-network
web:
hostname: web
depends_on:
- controllerdb
image: <windows base tomcat image>
restart: always
ports:
- 8080:8080
networks:
- app-network
networks:
app-network
the DNS for your database would be controllerdb:your-port,

Unable to start mysql with docker on Ubuntu 16.04

Am Unable to start mysql with docker on Ubuntu. Get the following error:
db_1_cc1214d5085c | ERROR: mysqld failed while attempting to check
config db_1_cc1214d5085c | command was: "mysqld --verbose --help"
db_1_cc1214d5085c | db_1_cc1214d5085c | mysqld: error while loading
shared libraries: libpthread.so.0: cannot stat shared object:
Permission denied
Content of docker compose file:
version: '2.4'
services:
db:
image: mysql:5.7
ports:
- "32000:3306"
environment:
MYSQL_ROOT_PASSWORD: root
# restart: always
volumes:
- ./data/db:/var/lib/mysql
Docker details:
Client:
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:48:57 2018
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:16:44 2018
OS/Arch: linux/amd64
Experimental: false
Also worth noting is that there is a non dockerized versionof MySQL installed and running on this server. Any help will be appreciated.
To start mysql service you'll need to have something like this in your docker-compose file
version: '3'
services:
<service-name>:
image: mysql:5.7
container_name: <container-name>
ports:
- "<host-port>:<container-port>"
environment:
- MYSQL_ROOT_PASSWORD=<root-password>
- MYSQL_DATABASE=<database-name>
volumes:
- <host-dir>:/var/lib/mysql
networks: ['stack']
networks:
stack:
driver: bridge
Make sure that <host-dir> you have permission with the current user executing the docker-compose up command.
The networks is used if you have multiple services that want to connect to the database they all should consume the same network which is stack in this example
looks like a permission problem on your host.

How to connect a Docker container of Grafana to a Docker conatiner of MySql?

I wish to set up 2 docker containers: grafana and mysql and to allow queries from the grafana to the mysql db.
I have an AWS machine, in which I built the following folders structure:
- docker
- docker-compose.yml
- grafana:
- config.ini
- dashboards:
- grafana_dashboard.json
- provisioning:
- dashboards:
- all.yml
- datasources:
- all.yml
- Dockerfile
- mysql:
- dbcreation.sql
- Dockerfile
- dashboards:
- import.sh
the content of the docker-compose.yml is:
version: '2'
services:
db-service:
build: './mysql'
container_name: mysql
restart: always
ports:
- "3306:3306"
networks:
net:
ipv4_address: 172.16.1.3
grafana-service:
build: './grafana'
container_name: grafana
restart: always
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_PASSWORD: "XXX1"
GF_AUTH_PROXY_ENABLED: "true"
GF_SECURITY_DATA_SOURCE_PROXY_WHITELIST: 172.16.1.3:3306
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_LOG_LEVEL: "debug"
depends_on:
- db-service
networks:
net:
ipv4_address: 172.16.1.4
networks:
net:
external: true
volumes:
grafanadata:
driver: local
mysqldata:
The dockerfile for the grafana:
FROM grafana/grafana:5.2.2
ADD ./provisioning /etc/grafana/provisioning
ADD ./dashboards /var/lib/grafana/dashboards
ENV DS_DB "grafana"
The content of the mysql/Dockerfile is:
FROM mysql:8.0.12
ENV MYSQL_ROOT_PASSWORD="XXX2"
ENV MYSQL_DATABASE="grafana"
ADD ./dbcreation.sql /docker-entrypoint-initdb.d/dbcreation.sql
EXPOSE 3306
The grafana_dashboard.json file has the exported json from the Grafana I had set up locally on my own computer.
The dbcreation.sql file has the exported data from the local DB I had set up locally on my own computer.
I'm running the following commands:
docker network create --gateway 172.16.1.1 --subnet 172.16.1.0/24 net
docker-compose up --build
I'm getting an error: "The authentication plugin is not supported"
when turning the log level of Grafana to debug I'm seeing this:
t=2018-08-19T10:55:20+0000 lvl=dbug msg=getEngine logger=tsdb.mysql connection="root:XXX2#tcp(172.16.1.3:3306)/grafana?collation=utf8mb4_unicode_ci&parseTime=true&loc=UTC&allowNativePasswords=true"
t=2018-08-19T10:55:47+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/tsdb/query status=500 remote_addr=XX.XXX.XXX.XXX time_ms=2 size=195 referer=http://XX.XXX.XXX.XXX:3000/datasources/edit/1
I have used the following sources already to set this up:
https://ops.tips/blog/initialize-grafana-with-preconfigured-dashboards/
https://storage.pardot.com/138181/61672/mysql_on_docker_how_to_containerize_your_database.pdf
Any help would be appreciated!
Thanks
As stated here:
go-mysql: authentication plugin not supported while connecting from go app container to mysql container
The problem was compatibility between the Grafana versions and the MySQL version.
Once moving to docker image mysql:5.7 (had to migrate the data too) - the issue was resolved (need to also change the COLLATION and CHAR_SET in the DB to downgrade from version 8.0.12 to 5.7).

can I Use mysql,oracle database as well as sql server on Same system

I have installed SQL-Server 2008 r2 on my system,but now i need to install MYSQL too. Is it possible to install MYSQL and SQL-Server side-by-side. Does installing both SQL-Server and MYSQL on same system affect each other?
Yes this is possible. However you have to make sure the ports they listen to are different.By default mysql uses port 3306 and SQL-server uses port 1433.They are both applications like any other application. With different processes, so they should run on the same machine without any conflicts. On setup just make sure you configure the ports well so that they do not use the same port, of which the system too should detect that the port is being used by another application.
The simple and clean answer to your question is Docker, i have created tutorial where MySQL, MSSQL, Oracle, PostgreSQL and MongoDB are setup and running simultaneously in single CentOS system with 3GB of RAM without affecting each other:
https://adhoctuts.com/run-mulitple-databases-in-single-machine-using-docker-vagrant/
https://www.youtube.com/watch?v=LeqkCoX28qg
below is the content of docker-compose.yml file from the tutorial, but you need the other files as well (all files are in following git repository: https://github.com/mamedshahmaliyev/adhoctuts/tree/master/docker/multiple_databases). If you need MySQL and MSSQL only just delete other services from docker-compose.yml and run docker-compose up:
# link to tutorial: https://adhoctuts.com/run-mulitple-databases-in-single-machine-using-docker-vagrant/
version: "3.1"
networks:
docker-network:
services:
# https://hub.docker.com/_/mysql
mysql_persistance: # service name
image: mysql:8
container_name: mysql_p # container_name
command: --default-authentication-plugin=mysql_native_password
volumes:
- /docker/mysql/data:/var/lib/mysql # for data persistance
- /docker/mysql/conf:/etc/mysql/conf.d # put all the custom configuration files from host to container
environment:
- MYSQL_ROOT_PASSWORD=AdHocTuts2019#
ports:
- "3309:3306" # map host port to container port
networks:
- docker-network
#restart: on-failure
mysql_no_persistance:
image: mysql:5.7
container_name: mysql_np
environment:
- MYSQL_ROOT_PASSWORD=AdHocTuts2019#
ports:
- "3308:3306"
networks:
- docker-network
# https://hub.docker.com/_/microsoft-mssql-server
mssql:
image: mcr.microsoft.com/mssql/server:2017-CU8-ubuntu
container_name: mssql
volumes:
- /docker/mssql/data:/var/opt/mssql
environment:
- SA_PASSWORD=AdHocTuts2019#
- ACCEPT_EULA=Y
- TZ=Asia/Baku
- MSSQL_PID=Express
ports:
- "1433:1433"
networks:
- docker-network
# https://hub.docker.com/_/oracle-database-enterprise-edition
# Accept Terms of Service for Oracle Database Enterprise Edition (Proceed to Checkout).
# Then in command line: docker login
# sqlplus sys/Oradoc_db1#ORCLDB as sysdba
oracle:
image: store/oracle/database-enterprise:12.2.0.1-slim
container_name: oracle
volumes:
- /docker/oracle/data:/ORCL # host path must have 777 permission or writable by docker oracle user
environment:
- DB_SID=ORCLDB
- DB_MEMORY=1GB
ports:
- "1521:1521"
networks:
- docker-network
# https://hub.docker.com/_/postgres
postgres:
image: postgres:12
container_name: postgres
volumes:
- /docker/postgre/data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=AdHocTuts2019#
- POSTGRES_USER=postgres
- POSTGRES_DB=docker_db
ports:
- "5432:5432"
networks:
- docker-network
# https://hub.docker.com/_/mongo
mongo:
image: mongo:3.4.21-xenial
container_name: mongo
volumes:
- /docker/mongo/data:/data/db
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=AdHocTuts2019#
ports:
- "27017:27017"
networks:
- docker-network