Cannot access Mysql Docker Container - mysql

I'm trying to access a docker container i have created.
Here are the files.
DockerFile
FROM mysql:5.7.24
LABEL MAINTAINER Myself <example#example.com>
LABEL description="Immagine DBMS MySql"
ADD dump.sql /docker-entrypoint-initdb.d
EXPOSE 3390
The dump.sql creates multiple databases with al the tables for each database.
(Is it possible to do this?)
docker-compose.yml
version: '3.3'
networks:
ntalphash:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.20.0.0/24
services:
mysql:
build:
context: .
image: mysql:5.7.24
restart: unless-stopped
container_name: mysqlsrv
volumes:
- data-volume:/var/lib/mysql
networks:
ntalphash:
ipv4_address: 172.20.0.2
ports:
- target: 3306
published: 3390
protocol: tcp
mode: host
environment:
- MYSQL_ROOT_PASSWORD=admin
volumes:
data-volume:
Here the commands i'm running on terminal:
Starting the container:
PS C:\Sql Server\MySql> docker-compose up Starting mysqlsrv ... done Attaching to mysqlsrv
mysqlsrv | 2020-06-14T11:07:57.454914Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysqlsrv | 2020-06-14T11:07:57.455943Z 0 [Note] mysqld (mysqld 5.7.24) starting as process 1 ...
mysqlsrv | 2020-06-14T11:07:57.458112Z 0 [Note] InnoDB: PUNCH HOLE support available
mysqlsrv | 2020-06-14T11:07:57.458143Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysqlsrv | 2020-06-14T11:07:57.458148Z 0 [Note] InnoDB: Uses event mutexes
mysqlsrv | 2020-06-14T11:07:57.458151Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mysqlsrv | 2020-06-14T11:07:57.458153Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
mysqlsrv | 2020-06-14T11:07:57.458155Z 0 [Note] InnoDB: Using Linux native AIO
mysqlsrv | 2020-06-14T11:07:57.458319Z 0 [Note] InnoDB: Number of pools: 1
mysqlsrv | 2020-06-14T11:07:57.458429Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysqlsrv | 2020-06-14T11:07:57.459511Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysqlsrv | 2020-06-14T11:07:57.465707Z 0 [Note] InnoDB: Completed initialization of buffer pool
mysqlsrv | 2020-06-14T11:07:57.467263Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysqlsrv | 2020-06-14T11:07:57.478653Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
mysqlsrv | 2020-06-14T11:07:57.490450Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysqlsrv | 2020-06-14T11:07:57.490629Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
mysqlsrv | 2020-06-14T11:07:57.505991Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
mysqlsrv | 2020-06-14T11:07:57.506650Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
mysqlsrv | 2020-06-14T11:07:57.506677Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
mysqlsrv | 2020-06-14T11:07:57.507334Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 101589607
mysqlsrv | 2020-06-14T11:07:57.507516Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysqlsrv | 2020-06-14T11:07:57.507702Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqlsrv | 2020-06-14T11:07:57.509875Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200614 11:07:57
mysqlsrv | 2020-06-14T11:07:57.511163Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
mysqlsrv | 2020-06-14T11:07:57.511449Z 0 [Warning] CA certificate ca.pem is self signed.
mysqlsrv | 2020-06-14T11:07:57.513138Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
mysqlsrv | 2020-06-14T11:07:57.513304Z 0 [Note] IPv6 is available.
mysqlsrv | 2020-06-14T11:07:57.513313Z 0 [Note] - '::' resolves to '::';
mysqlsrv | 2020-06-14T11:07:57.513327Z 0 [Note] Server socket created on IP: '::'.
mysqlsrv | 2020-06-14T11:07:57.515152Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
mysqlsrv | 2020-06-14T11:07:57.515869Z 0 [Warning] 'user' entry 'root#localhost' ignored in --skip-name-resolve mode.
mysqlsrv | 2020-06-14T11:07:57.515907Z 0 [Warning] 'user' entry 'mysql.session#localhost' ignored in --skip-name-resolve mode.
mysqlsrv | 2020-06-14T11:07:57.515915Z 0 [Warning] 'user' entry 'mysql.sys#localhost' ignored in --skip-name-resolve mode.
mysqlsrv | 2020-06-14T11:07:57.515920Z 0 [Warning] 'user' entry 'debian-sys-maint#localhost' ignored in --skip-name-resolve mode.
mysqlsrv | 2020-06-14T11:07:57.515937Z 0 [Warning] 'db' entry 'performance_schema mysql.session#localhost' ignored in --skip-name-resolve mode.
mysqlsrv | 2020-06-14T11:07:57.515939Z 0 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode.
mysqlsrv | 2020-06-14T11:07:57.515946Z 0 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode.
mysqlsrv | 2020-06-14T11:07:57.516857Z 0 [Warning] 'tables_priv' entry 'user mysql.session#localhost' ignored in --skip-name-resolve mode.
mysqlsrv | 2020-06-14T11:07:57.516888Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode.
mysqlsrv | 2020-06-14T11:07:57.521147Z 0 [Note] Event Scheduler: Loaded 0 events
mysqlsrv | 2020-06-14T11:07:57.521307Z 0 [Note] mysqld: ready for connections.
mysqlsrv | Version: '5.7.24' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
Checking for active containers:
C:\Users\Myself>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ec9f9070939e mysql:5.7.24 "docker-entrypoint.s…" 27 minutes ago Up About a minute 3390/tcp, 33060/tcp, 0.0.0.0:3390->3306/tcp mysqlsrv
64540c9d4bd1 portainer/portainer "/portainer" 7 days ago Up 46 minutes 0.0.0.0:9000->9000/tcp portainer
0345722e5fc3 mcr.microsoft.com/mssql/server:2017-latest-ubuntu "/opt/mssql/bin/nonr…" 6 months ago Up 46 minutes 0.0.0.0:1433->1433/tcp sqlserver
Then accessing the container and trying login mysql:
C:\Users\Myself>docker exec -ti mysqlsrv bash
root#ec9f9070939e:/# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
root#ec9f9070939e:/#
The password i'm typing is 'admin' as this is the password i've specified on the configuration file.
I am a beginner with Docker.
Anyone know what's going on?

Related

Docker mysql container does not allow remote connection

I have an error Access denied for user 'bonus_user'#'my-ip' (using password: YES) when trying to connect from my mysql client to dockerized mysql server on remote machine
My docker-compose file:
bonus_db:
container_name: bonus_db
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
restart: unless-stopped
ports:
- "3306:3306"
environment:
MYSQL_USER: bonus_user
MYSQL_PASSWORD: bonus_pass
MYSQL_DATABASE: bonus_db
MYSQL_ROOT_PASSWORD: root_pass
volumes:
- /var/lib/volumes/bonusdata:/var/lib/mysql
Here's also log of container starting:
bonus_db | 2020-11-14 15:06:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
bonus_db | 2020-11-14 15:06:05+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
bonus_db | 2020-11-14 15:06:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
bonus_db | 2020-11-14T15:06:06.470897Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
bonus_db | 2020-11-14T15:06:06.480712Z 0 [Note] mysqld (mysqld 5.7.31) starting as process 1 ...
bonus_db | 2020-11-14T15:06:06.502124Z 0 [Note] InnoDB: PUNCH HOLE support available
bonus_db | 2020-11-14T15:06:06.504807Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
bonus_db | 2020-11-14T15:06:06.504851Z 0 [Note] InnoDB: Uses event mutexes
bonus_db | 2020-11-14T15:06:06.504878Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
bonus_db | 2020-11-14T15:06:06.504894Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
bonus_db | 2020-11-14T15:06:06.504906Z 0 [Note] InnoDB: Using Linux native AIO
bonus_db | 2020-11-14T15:06:06.505684Z 0 [Note] InnoDB: Number of pools: 1
bonus_db | 2020-11-14T15:06:06.506021Z 0 [Note] InnoDB: Using CPU crc32 instructions
bonus_db | 2020-11-14T15:06:06.522229Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
bonus_db | 2020-11-14T15:06:06.548073Z 0 [Note] InnoDB: Completed initialization of buffer pool
bonus_db | 2020-11-14T15:06:06.554315Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
bonus_db | 2020-11-14T15:06:06.568903Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
bonus_db | 2020-11-14T15:06:06.603166Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
bonus_db | 2020-11-14T15:06:06.605892Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
bonus_db | 2020-11-14T15:06:06.654737Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
bonus_db | 2020-11-14T15:06:06.656736Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
bonus_db | 2020-11-14T15:06:06.656771Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
bonus_db | 2020-11-14T15:06:06.657961Z 0 [Note] InnoDB: Waiting for purge to start
bonus_db | 2020-11-14T15:06:06.708340Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 13750567
bonus_db | 2020-11-14T15:06:06.709023Z 0 [Note] Plugin 'FEDERATED' is disabled.
bonus_db | 2020-11-14T15:06:06.711205Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
bonus_db | 2020-11-14T15:06:06.715836Z 0 [Note] InnoDB: Buffer pool(s) load completed at 201114 15:06:06
bonus_db | 2020-11-14T15:06:06.721862Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
bonus_db | 2020-11-14T15:06:06.721918Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
bonus_db | 2020-11-14T15:06:06.723943Z 0 [Warning] CA certificate ca.pem is self signed.
bonus_db | 2020-11-14T15:06:06.724051Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
bonus_db | 2020-11-14T15:06:06.725417Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
bonus_db | 2020-11-14T15:06:06.725502Z 0 [Note] IPv6 is available.
bonus_db | 2020-11-14T15:06:06.725525Z 0 [Note] - '::' resolves to '::';
bonus_db | 2020-11-14T15:06:06.725562Z 0 [Note] Server socket created on IP: '::'.
bonus_db | 2020-11-14T15:06:06.740164Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
bonus_db | 2020-11-14T15:06:06.765251Z 0 [Note] Event Scheduler: Loaded 0 events
bonus_db | 2020-11-14T15:06:06.765978Z 0 [Note] mysqld: ready for connections.
bonus_db | Version: '5.7.31' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
I tried to log in into container on remote machine like this:
docker exec -i bonus_db mysql -ubonus_user -pbonus_pass
And it seems working, because if I pass wrong password here, it will give the same error Access denied. I've also tried to import data from sql file
docker exec -i bonus_db mysql -ubonus_user -pbonus_pass bonus_db < dump.sql
and it also seems working, it's processing a couple of seconds and then exits to the terminal. But I cant access database from my local machine and from other containers too.

MySQL connection refused from Node on first run only (docker-compose)

I'm trying to build out a NodeJS/MySQL stack, but am experiencing an intermittent issue.
Here is my docker compose file:
version: '3'
services:
db:
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
container_name: 'db'
networks:
- db-network
volumes:
- db-data:/var/lib/mysql
- ./db:/docker-entrypoint-initdb.d
forum:
image: "node:12"
user: "node"
working_dir: /home/node/app
depends_on:
- db
ports:
- 7000:3000
environment:
- NODE_ENV=development
- PORT=3000
volumes:
- ./server:/home/node/app
command: "npm start"
networks:
- db-network
adminer:
image: adminer
restart: always
networks:
- db-network
depends_on:
- db
ports:
- 7777:8080
environment:
ADMINER_DEFAULT_DB_DRIVER: mysql
ADMINER_DEFAULT_DB_HOST: db
volumes:
db-data:
networks:
db-network:
You can see that I've got an SQL script mapped into the initdb entrypoint. This is really simple SQL, it simply creates the db: CREATE DATABASE IF NOT EXISTS forum;
Inside the Node container I'm using knex to talk to the database. When I instantiate knex, I also run any outstanding migrations:
const environment = process.env.ENVIRONMENT || 'development'
const Knex = require('knex');
const knexConfig = require('../knexfile');
const knex = Knex(knexConfig[environment]);
async function init() {
try {
return await knex.migrate.latest();
} catch (error) {
console.log(error);
} finally {
return;
}
}
init();
module.exports = knex;
The problem i'm getting only appears on 'first up' o docker-compose (or more specifically when it needs to create the db-data volume). If I drop the volume docker-compose down -V I get the error when 'up-ing' again. The problem is your classic ECONNREFUSED:
Creating network "forum_db-network" with the default driver
Creating volume "forum_db-data" with default driver
Creating db ... done
Creating forum_adminer_1 ... done
Creating forum_forum_1 ... done
Attaching to db, forum_adminer_1, forum_forum_1
db | Initializing database
db | 2020-02-20T09:50:46.701629Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db | 2020-02-20T09:50:47.004757Z 0 [Warning] InnoDB: New log files created, LSN=45790
db | 2020-02-20T09:50:47.062521Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
db | 2020-02-20T09:50:47.122917Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7810f3c2-53c6-11ea-ba00-0242c0a81002.
db | 2020-02-20T09:50:47.126689Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
adminer_1 | [Thu Feb 20 09:50:47 2020] PHP 7.4.2 Development Server (http://[::]:8080) started
db | 2020-02-20T09:50:47.127637Z 1 [Warning] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
db | 2020-02-20T09:50:47.955961Z 1 [Warning] 'user' entry 'root#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:47.956454Z 1 [Warning] 'user' entry 'mysql.session#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:47.957026Z 1 [Warning] 'user' entry 'mysql.sys#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:47.957747Z 1 [Warning] 'db' entry 'performance_schema mysql.session#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:47.958212Z 1 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:47.958797Z 1 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:47.959520Z 1 [Warning] 'tables_priv' entry 'user mysql.session#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:47.960113Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode.
forum_1 |
forum_1 | > express-oauth-vuex-starter#1.0.0 start /home/node/app
forum_1 | > nodemon index.js
forum_1 |
forum_1 | [nodemon] 2.0.2
forum_1 | [nodemon] to restart at any time, enter `rs`
forum_1 | [nodemon] watching dir(s): *.*
forum_1 | [nodemon] watching extensions: js,mjs,json
forum_1 | [nodemon] starting `node index.js`
db | Database initialized
db | Initializing certificates
db | Generating a RSA private key
db | ........................................................................................................................+++++
db | ..........+++++
db | unable to write 'random state'
db | writing new private key to 'ca-key.pem'
db | -----
db | Generating a RSA private key
db | .........................................................................................+++++
db | .............+++++
db | unable to write 'random state'
db | writing new private key to 'server-key.pem'
db | -----
db | Generating a RSA private key
db | .....................................................+++++
db | .+++++
db | unable to write 'random state'
db | writing new private key to 'client-key.pem'
db | -----
db | Certificates initialized
db | MySQL init process in progress...
db | 2020-02-20T09:50:51.037907Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db | 2020-02-20T09:50:51.039423Z 0 [Note] mysqld (mysqld 5.7.24) starting as process 89 ...
db | 2020-02-20T09:50:51.044545Z 0 [Note] InnoDB: PUNCH HOLE support available
db | 2020-02-20T09:50:51.044653Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db | 2020-02-20T09:50:51.044701Z 0 [Note] InnoDB: Uses event mutexes
db | 2020-02-20T09:50:51.044745Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
db | 2020-02-20T09:50:51.044786Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db | 2020-02-20T09:50:51.044825Z 0 [Note] InnoDB: Using Linux native AIO
db | 2020-02-20T09:50:51.045705Z 0 [Note] InnoDB: Number of pools: 1
db | 2020-02-20T09:50:51.046113Z 0 [Note] InnoDB: Using CPU crc32 instructions
db | 2020-02-20T09:50:51.048701Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
db | 2020-02-20T09:50:51.060691Z 0 [Note] InnoDB: Completed initialization of buffer pool
db | 2020-02-20T09:50:51.064263Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db | 2020-02-20T09:50:51.076676Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
db | 2020-02-20T09:50:51.097380Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db | 2020-02-20T09:50:51.097533Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db | 2020-02-20T09:50:51.131620Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db | 2020-02-20T09:50:51.134052Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
db | 2020-02-20T09:50:51.134142Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
db | 2020-02-20T09:50:51.135177Z 0 [Note] InnoDB: Waiting for purge to start
db | 2020-02-20T09:50:51.185530Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 2591440
db | 2020-02-20T09:50:51.186329Z 0 [Note] Plugin 'FEDERATED' is disabled.
db | 2020-02-20T09:50:51.192075Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
db | 2020-02-20T09:50:51.192591Z 0 [Warning] CA certificate ca.pem is self signed.
db | 2020-02-20T09:50:51.194602Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db | 2020-02-20T09:50:51.197793Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200220 9:50:51
db | 2020-02-20T09:50:51.198483Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db | 2020-02-20T09:50:51.200316Z 0 [Warning] 'user' entry 'root#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:51.200460Z 0 [Warning] 'user' entry 'mysql.session#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:51.200532Z 0 [Warning] 'user' entry 'mysql.sys#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:51.200606Z 0 [Warning] 'db' entry 'performance_schema mysql.session#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:51.200656Z 0 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:51.200717Z 0 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:51.202731Z 0 [Warning] 'tables_priv' entry 'user mysql.session#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:51.202816Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:51.219832Z 0 [Note] Event Scheduler: Loaded 0 events
db | 2020-02-20T09:50:51.221248Z 0 [Note] mysqld: ready for connections.
db | Version: '5.7.24' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL)
forum_1 | Listening...
forum_1 | Error: connect ECONNREFUSED 192.168.16.2:3306
forum_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16)
forum_1 | at Protocol._enqueue (/home/node/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
forum_1 | at Protocol.handshake (/home/node/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
forum_1 | at Connection.connect (/home/node/app/node_modules/mysql/lib/Connection.js:116:18)
forum_1 | at /home/node/app/node_modules/knex/lib/dialects/mysql/index.js:69:18
forum_1 | From previous event:
forum_1 | at Client_MySQL.acquireRawConnection (/home/node/app/node_modules/knex/lib/dialects/mysql/index.js:64:12)
forum_1 | at create (/home/node/app/node_modules/knex/lib/client.js:291:39)
forum_1 | at processTicksAndRejections (internal/process/task_queues.js:97:5) {
forum_1 | errno: 'ECONNREFUSED',
forum_1 | code: 'ECONNREFUSED',
forum_1 | syscall: 'connect',
forum_1 | address: '192.168.16.2',
forum_1 | port: 3306,
forum_1 | fatal: true
forum_1 | }
db | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
db | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
db | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
db | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
db | 2020-02-20T09:50:54.889060Z 4 [Warning] 'user' entry 'root#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:54.889116Z 4 [Warning] 'user' entry 'mysql.session#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:54.889137Z 4 [Warning] 'user' entry 'mysql.sys#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:54.889164Z 4 [Warning] 'db' entry 'performance_schema mysql.session#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:54.889172Z 4 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:54.889188Z 4 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:54.890011Z 4 [Warning] 'tables_priv' entry 'user mysql.session#localhost' ignored in --skip-name-resolve mode.
db | 2020-02-20T09:50:54.890057Z 4 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode.
db |
db | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
db | mysql: [Warning] Using a password on the command line interface can be insecure.
db |
db |
db | 2020-02-20T09:50:54.915362Z 0 [Note] Giving 0 client threads a chance to die gracefully
db | 2020-02-20T09:50:54.915705Z 0 [Note] Shutting down slave threads
db | 2020-02-20T09:50:54.916456Z 0 [Note] Forcefully disconnecting 0 remaining clients
db | 2020-02-20T09:50:54.917013Z 0 [Note] Event Scheduler: Purging the queue. 0 events
db | 2020-02-20T09:50:54.917696Z 0 [Note] Binlog end
db | 2020-02-20T09:50:54.918665Z 0 [Note] Shutting down plugin 'ngram'
db | 2020-02-20T09:50:54.919138Z 0 [Note] Shutting down plugin 'partition'
db | 2020-02-20T09:50:54.919357Z 0 [Note] Shutting down plugin 'BLACKHOLE'
db | 2020-02-20T09:50:54.920107Z 0 [Note] Shutting down plugin 'ARCHIVE'
db | 2020-02-20T09:50:54.920322Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
db | 2020-02-20T09:50:54.921325Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
db | 2020-02-20T09:50:54.921840Z 0 [Note] Shutting down plugin 'MyISAM'
db | 2020-02-20T09:50:54.922751Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
db | 2020-02-20T09:50:54.923300Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
db | 2020-02-20T09:50:54.923360Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
db | 2020-02-20T09:50:54.923589Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
db | 2020-02-20T09:50:54.923959Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
db | 2020-02-20T09:50:54.924112Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
db | 2020-02-20T09:50:54.924269Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
db | 2020-02-20T09:50:54.924754Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
db | 2020-02-20T09:50:54.925454Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
db | 2020-02-20T09:50:54.925535Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
db | 2020-02-20T09:50:54.925688Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
db | 2020-02-20T09:50:54.925728Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
db | 2020-02-20T09:50:54.926261Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
db | 2020-02-20T09:50:54.926443Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
db | 2020-02-20T09:50:54.926836Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
db | 2020-02-20T09:50:54.927513Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
db | 2020-02-20T09:50:54.927560Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
db | 2020-02-20T09:50:54.927718Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
db | 2020-02-20T09:50:54.927806Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
db | 2020-02-20T09:50:54.927847Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
db | 2020-02-20T09:50:54.928201Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
db | 2020-02-20T09:50:54.928360Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
db | 2020-02-20T09:50:54.928817Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
db | 2020-02-20T09:50:54.929031Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
db | 2020-02-20T09:50:54.929717Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
db | 2020-02-20T09:50:54.929740Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
db | 2020-02-20T09:50:54.929898Z 0 [Note] Shutting down plugin 'INNODB_CMP'
db | 2020-02-20T09:50:54.929912Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
db | 2020-02-20T09:50:54.930509Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
db | 2020-02-20T09:50:54.930535Z 0 [Note] Shutting down plugin 'INNODB_TRX'
db | 2020-02-20T09:50:54.930549Z 0 [Note] Shutting down plugin 'InnoDB'
db | 2020-02-20T09:50:54.931131Z 0 [Note] InnoDB: FTS optimize thread exiting.
db | 2020-02-20T09:50:54.931746Z 0 [Note] InnoDB: Starting shutdown...
db | 2020-02-20T09:50:55.032188Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
db | 2020-02-20T09:50:55.032448Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 200220 9:50:55
If the volume already exists, I get no errors, knex connects and the migrations are run.
In the error log you can see that the Node container starts up directly after mysqld: ready for connections. However, you can see that after the Node error, the db container then runs init.sql. Presumably this means that knex is trying to connect to a specific database before it exists, which I guess could be the cause of the refused connection.
So I guess I'm looking for a way to defer the instantiation of the node container until after the MySQL container has run init.sql. I'm already using the depends_on docker compose property - are there any other docker options available to me?
There's no native solution that I'm aware of, I'm afraid.
For waiting for a service to become available in general, I've used wait-for-it, but in your case you'd need something to verify MySQL also contains the database your app requires.
Maybe a simple Node script that loops a connection and attempts to select the database before running your app proper.
In the end I solved this by setting the MYSQL_DATABASE environment variable for the MySQL container. From the MySQL image docs:
MYSQL_DATABASE
This variable is optional and allows you to specify the
name of a database to be created on image startup. If a user/password
was supplied (see below) then that user will be granted superuser
access (corresponding to GRANT ALL) to this database
db:
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: forum
MYSQL_ROOT_PASSWORD: root
container_name: 'db'
networks:
- db-network
volumes:
- db-data:/var/lib/mysql
In addition to this, I used is-port-reachable to hold initial migrations until the MySQL container is available.
const isPortReachable = require('is-port-reachable');
const environment = process.env.ENVIRONMENT || 'development'
const Knex = require('knex');
const knexConfig = require('../knexfile');
const knex = Knex(knexConfig[environment]);
async function init() {
let dbStatus = false;
while (!dbStatus) {
dbStatus = await isPortReachable(knexConfig[environment].connection.port, {host: knexConfig[environment].connection.host});
}
try {
return await knex.migrate.latest();
} catch (error) {
console.log(error);
}
}
init();
module.exports = knex;
Update
While the above did solve this specific problem, there was a raft of other issues that kept popping up - all to do with MySQL configuration. In the end I got tired of playing whack-a-mole and switched to Postgres (incredibly simple thanks to Knex). Span the image up and everything just worked...
If you are having issues with docker-compose, knex and mysql, my advice would be to just use Postgres!

Docker - MySQL mount/bind with local machine mysql data /var/lib/mysql

i have installed mysql on my local machine and i have docker installed in my machine i am converting my projects to Docker successfully i have deployed flask on container but i want to install mysql on container but mysql container should use my local machine data because data almost 100+Gb in size.
I have to do Same for mongodb.
Am i missing something for dockerize the existing mysql and mongodb.
OS: Ubuntu and default mysql path: /var/lib/mysql
I dont want to do import/export.
Below is my docker-compose.yml
version: "3"
services:
app:
build:
context: ./app
dockerfile: ./dockerfile
container_name: flaskPython
links:
- mysqldb
- mongodb
ports:
- "5000:5000"
myadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
ports:
- "8282:80"
environment:
- PMA_ARBITRARY=1
- PMA_HOST=${MYSQL_HOST}
restart: always
depends_on:
- mysqldb
- mongodb
mysqldb:
image: mysql:${MYSQL_VERSION}
container_name: ${MYSQL_HOST}
restart: 'always'
expose:
- '3306'
env_file:
- ".env"
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
ports:
- "8989:3306"
volumes:
#- ./data/db/mysql:/var/lib/mysql
- /var/lib/mysql:/var/lib/mysql
mongodb:
image: mongo
container_name: mongodb
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root
# if you wish to setup additional user accounts specific per DB or with different roles you can use following entry point
#no --auth is needed here as presence of username and password add this option automatically
command: mongod
ports:
- "27017:27017"
volumes:
#- ./data/db/mongo/001_users.js:/docker-entrypoint-initdb.d/001_users.js:ro
- ./mongo-entrypoint/:/docker-entrypoint-initdb.d/
- ./data/db/mongo:/usr/data/db
Logs:
2019-02-01T16:08:20.100825Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-02-01T16:08:20.101919Z 0 [Note] mysqld (mysqld 5.7.22) starting as process 1 ...
2019-02-01T16:08:20.104031Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-02-01T16:08:20.104043Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-02-01T16:08:20.104046Z 0 [Note] InnoDB: Uses event mutexes
2019-02-01T16:08:20.104048Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-02-01T16:08:20.104050Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2019-02-01T16:08:20.104052Z 0 [Note] InnoDB: Using Linux native AIO
2019-02-01T16:08:20.104214Z 0 [Note] InnoDB: Number of pools: 1
2019-02-01T16:08:20.104285Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-02-01T16:08:20.105476Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-02-01T16:08:20.110790Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-02-01T16:08:20.112288Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-02-01T16:08:20.123892Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-02-01T16:08:20.139921Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-02-01T16:08:20.139996Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-02-01T16:08:20.170786Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-02-01T16:08:20.173104Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2019-02-01T16:08:20.173143Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2019-02-01T16:08:20.174483Z 0 [Note] InnoDB: Waiting for purge to start
2019-02-01T16:08:20.224878Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 1529088986
2019-02-01T16:08:20.225403Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-02-01T16:08:20.225887Z 0 [Note] Plugin 'FEDERATED' is disabled.
2019-02-01T16:08:20.231185Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190201 16:08:20
2019-02-01T16:08:20.233231Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2019-02-01T16:08:20.233502Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2019-02-01T16:08:20.233535Z 0 [Note] IPv6 is available.
2019-02-01T16:08:20.233544Z 0 [Note] - '::' resolves to '::';
2019-02-01T16:08:20.233556Z 0 [Note] Server socket created on IP: '::'.
2019-02-01T16:08:20.236451Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2019-02-01T16:08:20.248740Z 0 [Warning] 'user' entry 'root#localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248832Z 0 [Warning] 'user' entry 'mysql.session#localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248857Z 0 [Warning] 'user' entry 'mysql.sys#localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248875Z 0 [Warning] 'user' entry 'debian-sys-maint#localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248921Z 0 [Warning] 'db' entry 'performance_schema mysql.session#localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248935Z 0 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.249216Z 0 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.256300Z 0 [Warning] 'tables_priv' entry 'user mysql.session#localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.256349Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.301149Z 0 [Note] Event Scheduler: Loaded 0 events
2019-02-01T16:08:20.301811Z 0 [Note] mysqld: ready for connections.
Version: '5.7.22' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
I want to use machine mysql data in mysql container so that i dont have to migrate 100+ gb data to mysql container, so that my mysql container will use my local machine mysql data for read and write purpose.
PS: i just want i dont migrate machine mysql data to mysql container so that my mysql container somehow link to my machine and use my local machine installed mysql data folder.

can't reach wordpress site on docker

I am trying to create a docker machine that will run 3 containers:
Wordpress, mysql and phpMyAdmin. This is my docker compose file:
version: '3.1'
services:
wordpress:
volumes:
- E:\Demo Sites\testSite\public_html:/var/www/html
depends_on:
- db
image: wordpress:latest
restart: unless-stopped
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: user2
WORDPRESS_DB_PASSWORD: pass2
WORDPRESS_DB_NAME: db2
db:
image: mysql:5.7
restart: always
ports:
- 3306:3306
environment:
MYSQL_DATABASE: db2
MYSQL_USER: user2
MYSQL_PASSWORD: pass2
MYSQL_ROOT_PASSWORD: test_pass2
volumes:
- db_data:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
links:
- db:db
restart: always
depends_on:
- db
ports:
- 9191:80
environment:
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: test_pass2
MYSQL_PASSWORD: test_pass2
volumes:
db_data:
I ran docker system prune in order to start fresh. Then, I ran the file using docker-compose up. phpMyAdmin works as expected, but I can't reach the wordpress site at 192.168.99.100:8080. These are the logs:
Creating demosites_db_1 ... done
Creating demosites_phpmyadmin_1 ... done
Creating demosites_wordpress_1 ... done
Attaching to demosites_db_1, demosites_phpmyadmin_1, demosites_wordpress_1
db_1 | 2018-12-25T14:30:06.003349Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1 | 2018-12-25T14:30:06.014038Z 0 [Note] mysqld (mysqld 5.7.24) starting as process 1 ...
db_1 | 2018-12-25T14:30:06.030769Z 0 [Note] InnoDB: PUNCH HOLE support available
db_1 | 2018-12-25T14:30:06.030841Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1 | 2018-12-25T14:30:06.030868Z 0 [Note] InnoDB: Uses event mutexes
db_1 | 2018-12-25T14:30:06.030890Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
db_1 | 2018-12-25T14:30:06.030911Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1 | 2018-12-25T14:30:06.030932Z 0 [Note] InnoDB: Using Linux native AIO
db_1 | 2018-12-25T14:30:06.043746Z 0 [Note] InnoDB: Number of pools: 1
db_1 | 2018-12-25T14:30:06.075840Z 0 [Note] InnoDB: Using CPU crc32 instructions
db_1 | 2018-12-25T14:30:06.084608Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
db_1 | 2018-12-25T14:30:06.147100Z 0 [Note] InnoDB: Completed initialization of buffer pool
db_1 | 2018-12-25T14:30:06.196456Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db_1 | 2018-12-25T14:30:06.245622Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
db_1 | 2018-12-25T14:30:06.503315Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1 | 2018-12-25T14:30:06.504395Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1 | 2018-12-25T14:30:06.739272Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1 | 2018-12-25T14:30:06.742497Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
db_1 | 2018-12-25T14:30:06.743304Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
db_1 | 2018-12-25T14:30:06.744156Z 0 [Note] InnoDB: Waiting for purge to start
db_1 | 2018-12-25T14:30:06.796032Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 12372193
db_1 | 2018-12-25T14:30:06.796536Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db_1 | 2018-12-25T14:30:06.797064Z 0 [Note] Plugin 'FEDERATED' is disabled.
db_1 | 2018-12-25T14:30:06.886235Z 0 [Note] InnoDB: Buffer pool(s) load completed at 181225 14:30:06
db_1 | 2018-12-25T14:30:06.912383Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
db_1 | 2018-12-25T14:30:06.916997Z 0 [Warning] CA certificate ca.pem is self signed.
db_1 | 2018-12-25T14:30:06.934450Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
db_1 | 2018-12-25T14:30:06.936498Z 0 [Note] IPv6 is available.
db_1 | 2018-12-25T14:30:06.937204Z 0 [Note] - '::' resolves to '::';
db_1 | 2018-12-25T14:30:06.937558Z 0 [Note] Server socket created on IP: '::'.
db_1 | 2018-12-25T14:30:06.959182Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db_1 | 2018-12-25T14:30:06.967176Z 0 [Warning] 'user' entry 'root#localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-12-25T14:30:06.967504Z 0 [Warning] 'user' entry 'mysql.session#localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-12-25T14:30:06.967822Z 0 [Warning] 'user' entry 'mysql.sys#localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-12-25T14:30:06.968512Z 0 [Warning] 'db' entry 'performance_schema mysql.session#localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-12-25T14:30:06.968914Z 0 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-12-25T14:30:06.969441Z 0 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-12-25T14:30:06.997582Z 0 [Warning] 'tables_priv' entry 'user mysql.session#localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-12-25T14:30:06.997923Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode.
db_1 | 2018-12-25T14:30:07.085365Z 0 [Note] Event Scheduler: Loaded 0 events
phpmyadmin_1 | phpMyAdmin not found in /var/www/html - copying now...
wordpress_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.4. Set the 'ServerName' directive globally to suppress this message
wordpress_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.4. Set the 'ServerName' directive globally to suppress this message
wordpress_1 | [Tue Dec 25 14:30:09.921193 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.13 configured -- resuming normal operations
phpmyadmin_1 | Complete! phpMyAdmin has been successfully copied to /var/www/html
phpmyadmin_1 | /usr/lib/python2.7/site-packages/supervisor/options.py:461: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
phpmyadmin_1 | 'Supervisord is running as root and it is searching '
phpmyadmin_1 | 2018-12-25 14:30:10,239 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
phpmyadmin_1 | 2018-12-25 14:30:10,240 INFO Included extra file "/etc/supervisor.d/nginx.ini" during parsing
phpmyadmin_1 | 2018-12-25 14:30:10,241 INFO Included extra file "/etc/supervisor.d/php.ini" during parsing
phpmyadmin_1 | 2018-12-25 14:30:10,276 INFO RPC interface 'supervisor' initialized
phpmyadmin_1 | 2018-12-25 14:30:10,277 CRIT Server 'unix_http_server' running without any HTTP authentication checking
phpmyadmin_1 | 2018-12-25 14:30:10,278 INFO supervisord started with pid 1
phpmyadmin_1 | 2018-12-25 14:30:11,283 INFO spawned: 'php-fpm' with pid 21
phpmyadmin_1 | 2018-12-25 14:30:11,291 INFO spawned: 'nginx' with pid 22
phpmyadmin_1 | [25-Dec-2018 14:30:11] NOTICE: fpm is running, pid 21
phpmyadmin_1 | [25-Dec-2018 14:30:11] NOTICE: ready to handle connections
phpmyadmin_1 | 2018-12-25 14:30:12,466 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
In addition, I can see that no folder is created under E:/Demo Sites. It used to work perfectly and therefor I am pretty lost on this one. Thanks in advance.
EDIT: I found it that if I write any path inside the site (i.e. 192.168.99.100:8080/aaa) it works and takes me to the wordpress installation page. I have absolutely no idea why, but it does work.
I think you need to specify that WordPress depends on PHP too

MySQL container failing to run initialisation scripts in Docker Compose

I am having issues getting my MySQL container to run some initialisation scripts (creating some databases) from Docker Compose. As per the documentation on Docker Hub, I mount the .sql files in /docker-entrypoint-initdb.d but to no avail.
My compose files is as follows:
version: '2'
services:
database:
image: mysql
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- ./scripts/db:/docker-entrypoint-initdb.d
myservice:
image: company/myservice
expose:
- "10001"
depends_on:
- database
links:
- database
environment:
SERVICE_PORT: 10001
DATABASE_URL: jdbc:mysql://database:3306/myservice?autoReconnect=true&useSSL=false&characterEncoding=UTF-8
And the contents of ./scripts/db is just 1 file init-databases.sql:
CREATE DATABASE myservice;
Once started up, MySQL is running, but the database is not created. The service container also successfully links to the MySQL container. Bashing into the MySQL container; the init scripts are successfully mounted in the correct location.
Can anyone see some obvious issues here?
LOGS FROM compose
database_1 | 2016-04-01T05:35:55.020279Z 0 [Note] mysqld (mysqld 5.7.11) starting as process 1 ...
database_1 | 2016-04-01T05:35:55.023277Z 0 [Note] InnoDB: PUNCH HOLE support available
database_1 | 2016-04-01T05:35:55.023305Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
database_1 | 2016-04-01T05:35:55.023316Z 0 [Note] InnoDB: Uses event mutexes
database_1 | 2016-04-01T05:35:55.023324Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
database_1 | 2016-04-01T05:35:55.023332Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
database_1 | 2016-04-01T05:35:55.023344Z 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2016-04-01T05:35:55.023491Z 0 [Note] InnoDB: Number of pools: 1
database_1 | 2016-04-01T05:35:55.023566Z 0 [Note] InnoDB: Using CPU crc32 instructions
database_1 | 2016-04-01T05:35:55.028689Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
database_1 | 2016-04-01T05:35:55.041026Z 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2016-04-01T05:35:55.047324Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
database_1 | 2016-04-01T05:35:55.061537Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
database_1 | 2016-04-01T05:35:55.076895Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2016-04-01T05:35:55.076987Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2016-04-01T05:35:55.095683Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2016-04-01T05:35:55.096484Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
database_1 | 2016-04-01T05:35:55.096540Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
database_1 | 2016-04-01T05:35:55.096931Z 0 [Note] InnoDB: Waiting for purge to start
database_1 | 2016-04-01T05:35:55.147986Z 0 [Note] InnoDB: 5.7.11 started; log sequence number 11992841
database_1 | 2016-04-01T05:35:55.148204Z 0 [Note] Plugin 'FEDERATED' is disabled.
database_1 | 2016-04-01T05:35:55.149262Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
database_1 | 2016-04-01T05:35:55.149443Z 0 [Warning] CA certificate ca.pem is self signed.
database_1 | 2016-04-01T05:35:55.150272Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2016-04-01T05:35:55.151068Z 0 [Note] InnoDB: Buffer pool(s) load completed at 160401 5:35:55
database_1 | 2016-04-01T05:35:55.152775Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
database_1 | 2016-04-01T05:35:55.154441Z 0 [Note] IPv6 is available.
database_1 | 2016-04-01T05:35:55.154553Z 0 [Note] - '::' resolves to '::';
database_1 | 2016-04-01T05:35:55.154571Z 0 [Note] Server socket created on IP: '::'.
database_1 | 2016-04-01T05:35:55.156680Z 0 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode.
database_1 | 2016-04-01T05:35:55.156738Z 0 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode.
database_1 | 2016-04-01T05:35:55.158280Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode.
database_1 | 2016-04-01T05:35:55.165273Z 0 [Note] Event Scheduler: Loaded 0 events
database_1 | 2016-04-01T05:35:55.173462Z 0 [Note] mysqld: ready for connections.
database_1 | Version: '5.7.11' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
Check if this is a docker-compose issue (like issue 115 which redirected to issue 2266)
I don't think the error is related to build, it's mostly likely volumes.
Compose preserves volumes so that you don't lose data (this will be better documented in the next release).
To remove those volumes run docker-compose rm -vf. The next time you docker-compose up it should start with fresh empty volumes.
According to hub.docker.com/mysql, check also if this is not a synchronization issue:
If there is no database initialized when the container starts, then a default database will be created. While this is the expected behavior, this means that it will not accept incoming connections until such initialization completes. This may cause issues when using automation tools, such as docker-compose, which start several containers simultaneously.