I have my docker compose as follows but am getting an operation not permitted mbind issue. It's been awhile but as far as I remember it was seeding with the db/init before. I have 2 sql files in there that I exported from a seeded db in the past via MySQL Workbench.
db_1 | 2022-05-17T03:52:16.766919Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.28' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
db_1 | mbind: Operation not permitted
db:
command: '--default-authentication-plugin=mysql_native_password'
environment:
- MYSQL_DATABASE=investing
- MYSQL_ROOT_PASSWORD=777
image: mysql:8.0.28
ports:
- "3307:3306"
restart: on-failure
volumes:
- "./db/init:/tmp/docker-entrypoint-initdb.d"
Very curious thing but apparently I now needed to add security options to docker compose. I haven't upgraded docker but I did upgrade my Linux OS. I can't think of any other major system changes to prompt the issue.
security_opt:
- seccomp:unconfined
db:
command: '--default-authentication-plugin=mysql_native_password'
environment:
- MYSQL_DATABASE=investing
- MYSQL_ROOT_PASSWORD=777
image: mysql:8.0.28
ports:
- "3307:3306"
restart: on-failure
security_opt:
- seccomp:unconfined
volumes:
- "./db/init:/tmp/docker-entrypoint-initdb.d"
My db/init is still no longer seeding but that may be out of the scope of this question.
Related
I am trying sample application using spring boot + docker-compose + mysql. Below is my docker-compose,yml file
mysql:
image: mysql:latest
container_name: mysql-db
restart: always
command: --default-authentication-plugin=mysql_native_password
ports:
- "33061:3306"
networks:
- spring-boot-mysql-net
environment:
MYSQL_DATABASE: practice_db
MYSQL_ROOT_PASSWORD: root
volumes:
- ./database_storage:/docker-entrypoint-initdb.d
practice-service:
container_name: practice-service
build:
context: ./
dockerfile: Dockerfile
ports:
- "8080:8080"
depends_on:
- mysql
networks:
- spring-boot-mysql-net
restart: on-failure
command: sh -c './wait-for mysql:3306 -- npm start'
phpMyAdmin:
image: phpMyAdmin/phpMyAdmin
container_name: phpMyAdmin
restart: always
depends_on:
- mysql
environment:
PMA_HOST: database
PMA_PORT: 3306
ports:
- "9091:80"
networks:
spring-boot-mysql-net:
driver: bridge
application. Properties
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://mysql:3306/practice_db
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
spring.jpa.hibernate.naming.physical-
strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
But my spring boot application giving error while connecting to MySQLDB
2023-02-11 16:31:10 com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
2023-02-11 16:31:10 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2023-02-11 16:31:10 Caused by: java.net.ConnectException: Connection refused
Also I am trying to run phpMyAdmin but that is also not connecting to MySQL. I am not sure MySQL container is starting or not because I can see logs of it as -
2023-02-11 16:31:42 2023-02-12T00:31:42.117825Z 0 [System] [MY-010931] [Server]
/usr/sbin/mysqld: ready for connections. Version: '8.0.32' socket: '
/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2023-02-11 16:31:30 2023-02-12 00:31:30+00:00 [Note] [Entrypoint]: Temporary server started.
2023-02-11 16:31:30 '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2023-02-11 16:31:36 2023-02-12 00:31:36+00:00 [Note] [Entrypoint]: Creating database
practice-db
2023-02-11 16:31:36
2023-02-11 16:31:36 2023-02-12 00:31:36+00:00 [Note] [Entrypoint]: Stopping temporary server
2023-02-11 16:31:40 2023-02-12 00:31:40+00:00 [Note] [Entrypoint]: Temporary server stopped
2023-02-11 16:31:40
2023-02-11 16:31:40 2023-02-12 00:31:40+00:00 [Note] [Entrypoint]: MySQL init process done.
Ready for start up.
I have example in github which works:
https://github.com/armdev/docker-mysql
My docker compose:
version: '3'
services:
mysqlnode:
image: mysqlnode
build: ./mysqlnode
container_name: "mysqlnode"
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_USER=admin
- MYSQL_PASSWORD=root
- MYSQL_DATABASE=flownet
volumes:
- /opt/mysql/logs/:/opt/mysql/logs
- /opt/mysql/data:/var/lib/mysql
ports:
- 3306:3306
networks:
- flownet
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: "phpmyadmin"
links:
- mysqlnode
ports:
- 9191:80
environment:
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: root
PMA_HOST: mysqlnode
networks:
- flownet
networks:
flownet:
driver: bridge
MySQL user/password root:root
Once I run docker-compose up, it takes over 4 minutes for my mysql container to log out the line.
db_1 | 2021-03-09T08:29:28.459612Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
The line is important because it is only after its respective process is finished, that I can make connections to the database.
This is my docker setup.
docker-compose.yml
version: '3.1'
services:
php:
build:
context: .
dockerfile: Dockerfile
ports:
- 80:80
volumes:
- ./src:/var/www/html
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
adminer:
image: adminer
restart: always
ports:
- 8080:8080
Dockerfile
FROM php:7.2-apache
RUN docker-php-ext-install mysqli
I have an i7-2600k and 16GB of ram.
I don't think my PC is potato enough to be this slow.
Any help on how I can speed up this process?
I know this is a duplicate of this, but since that was never answered, I am re-posting this question.
I am trying to build a basic connection of php-apache and mysql containers.
docker-compose.yml
version: '3.1'
services:
php:
build:
context: .
dockerfile: Dockerfile
ports:
- 80:80
volumes:
- ./src:/var/www/html
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
# Exposing the ports doesn't help either
# ports:
# - 3306:3306
environment:
MYSQL_ROOT_PASSWORD: example
adminer:
image: adminer
restart: always
ports:
- 8080:8080
Dockerfile
FROM php:7.2-apache
RUN docker-php-ext-install mysqli
I run a simple docker-compose up command, and access Adminer on localhost:8080.
However, despite using the default login details, i.e
server: db
username: root
password: example
I get the error SQLSTATE[HY000] [2002] Connection refused.
Screenshot:
I think the issue might be some configuration issue on my local machine, because I couldn't use docker based LAMP stacks made by other people too.
Any help is greatly appreciated,
Thank You!
Turns out Patience was the answer.
If I wait long enough(around 4.5 minutes), the mysql container lets out a small log detail.
db_1 | 2021-03-09T08:21:03.882088Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
After that the login in works.
Note: There is a similar line that is logged, but that is regarding port 0, this is 3306. Attempting a failure immediately after that fails.
One must wait for the line with port 3306.
If any of you can give me feedback or advice on how I could make my mysql container initialize faster,
I'd greatly appreciate it.
I am using Docker-Compose and wait-for-it to start my backend with Node.js once the MySQL service is ready to receive connections. My problem is that the script does not realize the connection is ready by itself. I can make it work if I set the timeout to 20s since MySQL would be running by then, but that could change in different environments and the app would crash if it took more time for a specific environment. I want it to check it periodically since I think it is the right thing to do.
This is my docker-compose.yml:
version: "3.8"
services:
app:
image: pfmc
ports:
- 4005:4005
working_dir: /usr/src/app
command: sh -c './wait-for-it.sh -t 0 db:3306 -- npm start'
environment:
MYSQL_ROOT_PASSWORD: pfmc123
MYSQL_HOST: mysql
MYSQL_USER: root
MYSQL_PASSWORD: pfmc123
MYSQL_DATABASE: pfmc
mysql:
image: mysql:5
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- ./db-startup:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: pfmc123
MYSQL_DATABASE: pfmc
The logs:
app_1 | wait-for-it.sh: waiting for db:3306 without a timeout
mysql_1 | 2020-05-25 19:59:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.30-1debian10 started.
mysql_1 | 2020-05-25 19:59:58+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql_1 | 2020-05-25 19:59:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.30-1debian10 started.
mysql_1 | 2020-05-25 19:59:58+00:00 [Note] [Entrypoint]: Initializing database files
and it stays at this point:
mysql_1 | 2020-05-25T20:00:08.243448Z 0 [Note] mysqld: ready for connections.
mysql_1 | Version: '5.7.30' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
Thank you very much for your help.
You do have one issues in here: your MySQL container is a service named mysql not db you should either adapt the service to be named db or the wait-for-it invocation to poll on a connection to mysql:3306
All together, your docker-compose.yml should look like this – I added the fix with comment stating #fixme:
version: "3.8"
services:
app:
image: pfmc
ports:
- 4005:4005
working_dir: /usr/src/app
command: sh -c './wait-for-it.sh -t 0 db:3306 -- npm start'
environment:
MYSQL_ROOT_PASSWORD: pfmc123
# A first #fixme is here
MYSQL_HOST: db
MYSQL_USER: root
MYSQL_PASSWORD: pfmc123
MYSQL_DATABASE: pfmc
# And a second #fixme is here
db:
image: mysql:5
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- ./db-startup:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: pfmc123
MYSQL_DATABASE: pfmc
I am trying to install wordpress with mysql via docker but I have communication errors between the container of the DB and the wordpress container.
here is my docker-compose.yml file
version: '3'
services:
db:
image: mysql:latest
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
links:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
If I execute the "docker-compose up -d" command and that I open the logs of the wordpress container I have this error:
...
wordpress_1 | Warning: mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in Standard input code on line 22
wordpress_1 |
wordpress_1 | Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in Standard input code on line 22
wordpress_1 |
wordpress_1 | MySQL Connection Error: (2054) The server requested authentication method unknown to the client
...
I added command: '--default-authentication plugin=mysql_native_password' in the db section and i changed the mysql version to 5.7 but it did not help me solve the problem.
I also visited these discussions :
Wordpress on docker-compose no run
https://serverfault.com/questions/880773/unable-to-access-wordpress-site-created-as-a-docker-stack/880777#880777
https://github.com/docker-library/wordpress/issues/313
Thank you in advance for your proposals.
It seems that WordPress/PHP doesn't support MySQL v8 yet. Even wordpress docker image readme suggests to use MySQL v5.7. After changing mysql version to v5.7, you might notice that MySQL container crashes with an error similar to below:
...
db_1 | 2019-01-28T18:45:24.611045Z 0 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4800!
db_1 | 2019-01-28 18:45:24 0x7f00e013a740 InnoDB: Assertion failure in thread 139641736111936 in file ut0ut.cc line 942
db_1 | InnoDB: We intentionally generate a memory trap.
...
To fix this, easiest way is to delete the MySQL docker volume using docker-compose down -v. After that, docker-compose up -d should work.
If that still doesn't work, use the docker-compose example from https://hub.docker.com/_/wordpress/. Adding it here in case it gets pulled down in future.
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'