I'm trying to start a docker container from the vanilla mariadb image from docker hub using docker-compose. While everything previously worked, I'm now getting the error message Can't create/write to file '/tmp/ibLTxiq7' (Errcode: 13 "Permission denied"). Here's the full log:
139707238336448 [Note] /usr/sbin/mysqld (mysqld 10.1.14-MariaDB-1~jessie) starting as process 51 ...
139707238336448 [Note] InnoDB: Using mutexes to ref count buffer pool pages
139707238336448 [Note] InnoDB: The InnoDB memory heap is disabled
139707238336448 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
139707238336448 [Note] InnoDB: Memory barrier is not used
139707238336448 [Note] InnoDB: Compressed tables use zlib 1.2.8
139707238336448 [Note] InnoDB: Using Linux native AIO
139707238336448 [Note] InnoDB: Using SSE crc32 instructions
139707238336448 [ERROR] mysqld: Can't create/write to file '/tmp/ibLTxiq7' (Errcode: 13 "Permission denied")
7f10205047c0 InnoDB: Error: unable to create temporary file; errno: 13
139707238336448 [ERROR] Plugin 'InnoDB' init function returned error.
139707238336448 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
139707238336448 [ERROR] Unknown/unsupported storage engine: InnoDB
139707238336448 [ERROR] Aborting
I don't understand, does the /tmp folder in the log refer to the host machine or the container? How would I fix this issue?
The command I'm trying to run (as root user) is docker-compose up db. I've checked that there indeed is space on the disk. My OS Ubuntu 16.04.
Update: My docker-compose.yml-file
https-portal:
image: steveltn/https-portal
ports:
- '80:80'
- '443:443'
links:
- wordpress
restart: always
environment:
DOMAINS: 'domain.com -> http://wordpress'
STAGE: 'production'
wordpress:
image: wordpress
links:
- db:mysql
volumes:
- ~/wordpress/wp_html:/var/www/html
db:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: [---]
Update 2:
I seem to have (at least temporarily) solved the problem, rather surprisingly, by adding a volume mount path for the db container:
db:
image: mariadb
volumes:
- /data/maridb:/var/lib/mysql
However this does not actually affect anything, it just prints a warning that the volume mount is not used (and indeed it isn't) because the container has previously been created with a different volume and the old one is used. Still, the original problem disappears. Any thoughts on what causes this behavior?
Related
Each time I start my docker desktop application into Windows 11 OS,
It launch automatically a container into a docker-compose structure.
But not the others containers into this docker-compose.
I dealing with a MariaDB container...
My Apache container and my PHP container not run automatically. Just MariaDB
This is my docker-compose.yml file :
version: '3'
services:
apache:
build: ./docker/apache
container_name: projectx_apache
tty: true
ports:
- '443:443'
depends_on:
- php
- mariadb
volumes:
- ./:/var/www/projectx/
php:
build: ./docker/php
container_name: projectx_php
tty: true
volumes:
- ./:/var/www/projectx/
mariadb:
build: ./docker/mariadb
container_name: projectx_mariadb
restart: always
tty: true
environment:
MYSQL_ROOT_PASSWORD: docker
MYSQL_DATABASE: projectx
MYSQL_USER: docker
MYSQL_PASSWORD: docker
ports:
- '3306:3306'
this is my Dockerfile for MariaDB container :
FROM mariadb:latest
ENV MYSQL_ROOT_PASSWORD docker
ENV MYSQL_DATABASE projectx
ENV MYSQL_USER root
ENV MYSQL_PASSWORD docker
RUN apt-get -y update
RUN apt-get -y install vim
EXPOSE 3310
CMD ["mysqld"]
And this is my log container when It start automatically :
2022-11-15 14:16:33+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.9.4+maria~ubu2204 started.
2022-11-15 14:16:33+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-11-15 14:16:33+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.9.4+maria~ubu2204 started.
2022-11-15 14:16:34+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
2022-11-15 14:16:34 0 [Note] mysqld (server 10.9.4-MariaDB-1:10.9.4+maria~ubu2204) starting as process 1 ...
2022-11-15 14:16:34 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-11-15 14:16:34 0 [Note] InnoDB: Number of transaction pools: 1
2022-11-15 14:16:34 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-11-15 14:16:34 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2022-11-15 14:16:34 0 [Warning] mysqld: io_uring_queue_init() failed with ENOMEM: try larger memory locked limit, ulimit -l, or https://mariadb.com/kb/en/systemd/#configuring-limitmemlock under systemd (262144 bytes required)
2022-11-15 14:16:34 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
2022-11-15 14:16:34 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
2022-11-15 14:16:34 0 [Note] InnoDB: Completed initialization of buffer pool
2022-11-15 14:16:34 0 [Note] InnoDB: File system buffers for log disabled (block size=4096 bytes)
2022-11-15 14:16:34 0 [Note] InnoDB: 128 rollback segments are active.
2022-11-15 14:16:34 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2022-11-15 14:16:34 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2022-11-15 14:16:34 0 [Note] InnoDB: log sequence number 1489638494; transaction id 8288
2022-11-15 14:16:34 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-11-15 14:16:34 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-11-15 14:16:34 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
2022-11-15 14:16:34 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-11-15 14:16:34 0 [Note] Server socket created on IP: '::'.
2022-11-15 14:16:34 0 [Note] mysqld: ready for connections.
Version: '10.9.4-MariaDB-1:10.9.4+maria~ubu2204' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
2022-11-15 14:16:34 0 [Note] InnoDB: Buffer pool(s) load completed at 221115 14:16:34
Do you have an idea why this container start automatically ?
The reason for automatic start here is restart: always on MariaDB container,
It will start the container when the docker daemon restart. See
restart policy
I have a dockerized app and use the following docker-compose.yml file:
version: '3.7'
services:
app:
restart: always
build: ./app
ports:
- "8501:8501"
env_file:
- .env
command: streamlit run Main.py
networks:
- streamlit_network
mariadb:
image: mariadb:10.5.17
ports:
- "3306:3306"
volumes:
- db_data:/var/lib/mysql
- db_conf:/etc/mysql/conf.d
environment:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "db"
MYSQL_USER: "user"
MYSQL_PASSWORD: "password"
networks:
- streamlit_network
nginx:
restart: always
build: ./nginx
ports:
- "80:80"
depends_on:
- app
- mariadb
networks:
- streamlit_network
volumes:
db_data:
db_conf:
networks:
streamlit_network:
driver: bridge
I am able to access mysql using the following commands:
mysql -h <ip-address where database is hosted> -p -u username database
inside of my ubuntu machine which has a host IP of
How do I achieve the same within docker container
I believe '172.18.0.3' is a randomly generated ip address by docker as the IP address did change to '172.18.0.2' on another occasion.
The .env file is:
host="mariadb"
user="user"
password="password"
database="db"
port="3306"
This is the trace for mariadb when I am running docker-compose up:
mariadb_1 | 2022-10-27 12:20:24+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.9.3+maria~ubu2204 started.
mariadb_1 | 2022-10-27 12:20:25+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mariadb_1 | 2022-10-27 12:20:25+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.9.3+maria~ubu2204 started.
mariadb_1 | 2022-10-27 12:20:26+00:00 [Note] [Entrypoint]: MariaDB upgrade information missing, assuming required
mariadb_1 | 2022-10-27 12:20:26+00:00 [Note] [Entrypoint]: MariaDB upgrade (mariadb-upgrade) required, but skipped due to $MARIADB_AUTO_UPGRADE setting
mariadb_1 | 2022-10-27 12:20:26 0 [Note] mariadbd (server 10.9.3-MariaDB-1:10.9.3+maria~ubu2204) starting as process 1 ...
mariadb_1 | 2022-10-27 12:20:26 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
mariadb_1 | 2022-10-27 12:20:26 0 [Note] InnoDB: Number of transaction pools: 1
mariadb_1 | 2022-10-27 12:20:26 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
mariadb_1 | 2022-10-27 12:20:26 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
mariadb_1 | 2022-10-27 12:20:26 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
mariadb_1 | 2022-10-27 12:20:26 0 [Note] InnoDB: Completed initialization of buffer pool
mariadb_1 | 2022-10-27 12:20:26 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
mariadb_1 | 2022-10-27 12:20:27 0 [Note] InnoDB: 128 rollback segments are active.
mariadb_1 | 2022-10-27 12:20:27 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
mariadb_1 | 2022-10-27 12:20:27 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
mariadb_1 | 2022-10-27 12:20:27 0 [Note] InnoDB: log sequence number 35204; transaction id 8
mariadb_1 | 2022-10-27 12:20:27 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mariadb_1 | 2022-10-27 12:20:27 0 [Note] Plugin 'FEEDBACK' is disabled.
mariadb_1 | 2022-10-27 12:20:27 0 [Note] InnoDB: Buffer pool(s) load completed at 221027 12:20:27
mariadb_1 | 2022-10-27 12:20:27 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some plugins may be not loaded
mariadb_1 | 2022-10-27 12:20:28 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
mariadb_1 | 2022-10-27 12:20:28 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
mariadb_1 | 2022-10-27 12:20:28 0 [Note] Server socket created on IP: '0.0.0.0'.
mariadb_1 | 2022-10-27 12:20:28 0 [Note] Server socket created on IP: '::'.
mariadb_1 | 2022-10-27 12:20:28 0 [ERROR] Missing system table mysql.proxies_priv; please run mysql_upgrade to create it
mariadb_1 | 2022-10-27 12:20:28 0 [ERROR] Missing system table mysql.roles_mapping; please run mysql_upgrade to create it
mariadb_1 | 2022-10-27 12:20:28 0 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them
mariadb_1 | 2022-10-27 12:20:28 0 [ERROR] Can't open the mysql.func table. Please run mysql_upgrade to create it.
mariadb_1 | 2022-10-27 12:20:28 0 [ERROR] Cannot open mysql.event
mariadb_1 | 2022-10-27 12:20:28 0 [ERROR] mariadbd: Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.
mariadb_1 | 2022-10-27 12:20:28 1 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist
mariadb_1 | 2022-10-27 12:20:28 0 [Note] mariadbd: ready for connections.
mariadb_1 | Version: '10.9.3-MariaDB-1:10.9.3+maria~ubu2204' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
mariadb_1 | 2022-10-27 12:27:27 3 [Warning] Aborted connection 3 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.2' (This connection closed normally without authentication)
mariadb_1 | 2022-10-27 12:35:05 4 [Warning] Aborted connection 4 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.2' (This connection closed normally without authentication)
I am trying to deploy mariadb to my local kubernetes cluster. I'm building the image with the following Dockerfile:
FROM mariadb:10.2
ENV MYSQL_DATABASE=k8_demo \
MYSQL_ROOT_PASSWORD=***** \
MYSQL_ROOT_HOST=%
ADD mysql.cnf /etc/mysql/conf.d
ADD startup.sql /docker-entrypoint-initdb.d
EXPOSE 3306
startup.sql:
GRANT USAGE ON *.* TO 'root'#'%' IDENTIFIED BY '*****';
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%';
FLUSH PRIVILEGES;
mysql.cnf:
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
# Where the database files are stored inside the container
datadir = /var/lib/mysql
# My application special configuration
max_allowed_packet = 256M
sql-mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION'
# Accept connections from any IP address
bind-address = 0.0.0.0
Deploying the following deployment.yaml file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysqldb
labels:
app: mysqldb
spec:
replicas: 1
template:
metadata:
name: mysqldb
labels:
app: mysqldb
spec:
containers:
- name: mysqldb
image: manuel/mysqldb
ports:
- containerPort: 3306
env:
- name: MYSQL_DATABASE
valueFrom:
configMapKeyRef:
name: mysqldb
key: db-name
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysqldb
key: db-password
imagePullPolicy: Never
restartPolicy: Always
selector:
matchLabels:
app: mysqldb
---
apiVersion: v1
kind: Service
metadata:
name: mysqldb
spec:
selector:
app: mysqldb
ports:
- port: 3307
The pod log as follows is not really helpful:
2020-05-19 15:13:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.2.31+maria~bionic started.
2020-05-19 15:13:17+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-05-19 15:13:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.2.31+maria~bionic started.
2020-05-19 15:13:18+00:00 [Note] [Entrypoint]: Initializing database files
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
2020-05-19 15:13:20+00:00 [Note] [Entrypoint]: Database files initialized
2020-05-19 15:13:20+00:00 [Note] [Entrypoint]: Starting temporary server
2020-05-19 15:13:20+00:00 [Note] [Entrypoint]: Waiting for server startup
2020-05-19 15:13:20 139865539991232 [Note] mysqld (mysqld 10.2.31-MariaDB-1:10.2.31+maria~bionic) starting as process 124 ...
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Uses event mutexes
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Using Linux native AIO
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Number of pools: 1
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Using SSE2 crc32 instructions
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Completed initialization of buffer pool
2020-05-19 15:13:20 139864817927936 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Highest supported file format is Barracuda.
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: 128 out of 128 rollback segments are active.
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: Waiting for purge to start
2020-05-19 15:13:20 139865539991232 [Note] InnoDB: 5.7.29 started; log sequence number 1615502
2020-05-19 15:13:20 139864578180864 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-05-19 15:13:20 139864578180864 [Note] InnoDB: Buffer pool(s) load completed at 200519 15:13:20
2020-05-19 15:13:20 139865539991232 [Note] Plugin 'FEEDBACK' is disabled.
2020-05-19 15:13:20 139865539991232 [Warning] 'user' entry 'root#mysqldb-5fcbfd4df8-qdpfq' ignored in --skip-name-resolve mode.
2020-05-19 15:13:20 139865539991232 [Warning] 'proxies_priv' entry '#% root#mysqldb-5fcbfd4df8-qdpfq' ignored in --skip-name-resolve mode.
2020-05-19 15:13:20 139865539991232 [Note] Reading of all Master_info entries succeeded
2020-05-19 15:13:20 139865539991232 [Note] Added new Master_info '' to hash table
2020-05-19 15:13:20 139865539991232 [Note] mysqld: ready for connections.
Version: '10.2.31-MariaDB-1:10.2.31+maria~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
2020-05-19 15:13:21+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
2020-05-19 15:13:24 139864904218368 [Warning] 'proxies_priv' entry '#% root#mysqldb-5fcbfd4df8-qdpfq' ignored in --skip-name-resolve mode.
2020-05-19 15:13:24+00:00 [Note] [Entrypoint]: Creating database mysqldb
mysql: unknown option '--"'
I'm now looking into https://kubernetes.io/docs/tasks/run-application/run-single-instance-stateful-application/ since it might have something to do with the volume...
https://github.com/docker-library/mariadb/issues/76
What option is it referring to? Is there a way to get more information, since opening a shell is not possible since the container keeps crashing.
edit: added content of startup.sql and mysql.cnf
edit: typo
This morning i try to install Docker on my laptop (windows10),
(My Docker use hyper-v)
I try to use this basic docker-compose
version: '2'
services:
mariadb:
image: mariadb
container_name: mariadb
ports:
- "3306:3306"
volumes:
- ./mysql1/:/var/lib/mysql
environment:
MYSQL_USER : root
MYSQL_ROOT_PASSWORD: root
I have some error on running :
docker-compose up
Creating mariadb
Attaching to mariadb
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] mysqld (mysqld 10.1.22-MariaDB-1~jessie) starting as process 1 ...
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] InnoDB: Using mutexes to ref count buffer pool pages
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] InnoDB: The InnoDB memory heap is disabled
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] InnoDB: Compressed tables use zlib 1.2.8
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] InnoDB: Using Linux native AIO
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] InnoDB: Using SSE crc32 instructions
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] InnoDB: Initializing buffer pool, size = 256.0M
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] InnoDB: Completed initialization of buffer pool
mariadb | 2017-04-04 8:29:00 140557637724096 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 0 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
mariadb | 2017-04-04 8:29:00 140557637724096 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
mariadb | 2017-04-04 8:29:00 140557637724096 [ERROR] Plugin 'InnoDB' init function returned error.
mariadb | 2017-04-04 8:29:00 140557637724096 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
mariadb | 2017-04-04 8:29:00 140557637724096 [Note] Plugin 'FEEDBACK' is disabled.
mariadb | 2017-04-04 8:29:00 140557637724096 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
mariadb | 2017-04-04 8:29:00 140557637724096 [ERROR] Unknown/unsupported storage engine: InnoDB
mariadb | 2017-04-04 8:29:00 140557637724096 [ERROR] Aborting
mariadb |
mariadb exited with code 1
after running my directory ./mysql1/ and subfile was created :
C:\USERS\--------\DOCUMENTS\DOCKER\MARIADB\MYSQL1
| aria_log.00000001
| aria_log_control
| ibdata1
|
\---mysql
Yes I know that it's about my volumes (something about permissions or access or ...)
I have no ideas how solve it.
I was experiencing the same issue and the only way I could figure out how to resolve this was to delete the MARIADB\MYSQL1 folder. Yes, I lost all of the database records from all of my development sites, but for me, it was all test information anyway so no real data was lost.
After I deleted the MYSQL1 folder, I ran:
docker-compose build --no-cache MariaDB
Then I started up the container:
docker-compose up -d mariadb
The error finally went away and I was able to use my MariaDB container again. Hope this helps someone in the future!
Using the following docker-compose.yml file
version: '2'
services:
wordpress:
image: wordpress
ports:
- 8080:80
environment:
WORDPRESS_DB_NAME: my_db
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: password
volumes:
- ./src:/var/www/html
mysql:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- ./data_dir:/var/lib/mysql
when running docker-compose up commande,its giving me following error
Starting wp_mysql_1
Starting wp_wordpress_1
Attaching to wp_mysql_1, wp_wordpress_1
wordpress_1 |
wordpress_1 | Warning: mysqli::mysqli(): (HY000/2002): Connection refused in - on line 19
wordpress_1 |
wordpress_1 | MySQL Connection Error: (2002) Connection refused
mysql_1 | 2016-11-28 15:47:02 139858949081024 [Note] mysqld (mysqld 10.1.19-MariaDB-1~jessie) starting as process 1
...
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] InnoDB: Using mutexes to ref count buffer pool pages
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] InnoDB: The InnoDB memory heap is disabled
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory
barrier
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] InnoDB: Compressed tables use zlib 1.2.8
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] InnoDB: Using Linux native AIO
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] InnoDB: Using SSE crc32 instructions
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] InnoDB: Initializing buffer pool, size = 256.0M
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] InnoDB: Completed initialization of buffer pool
mysql_1 | 2016-11-28 15:47:03 139858949081024 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different
size 0 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages
!
mysql_1 | 2016-11-28 15:47:03 139858949081024 [ERROR] InnoDB: Could not open or create the system tablespace. If yo
u tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in
my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote th
ose files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain
your precious data!
mysql_1 | 2016-11-28 15:47:03 139858949081024 [ERROR] Plugin 'InnoDB' init function returned error.
mysql_1 | 2016-11-28 15:47:03 139858949081024 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
mysql_1 | 2016-11-28 15:47:03 139858949081024 [Note] Plugin 'FEEDBACK' is disabled.
mysql_1 | 2016-11-28 15:47:03 139858949081024 [ERROR] Could not open mysql.plugin table. Some plugins may be not lo
aded
mysql_1 | 2016-11-28 15:47:03 139858949081024 [ERROR] Unknown/unsupported storage engine: InnoDB
mysql_1 | 2016-11-28 15:47:03 139858949081024 [ERROR] Aborting
mysql_1 |
wp_mysql_1 exited with code 1
wordpress_1 |
wordpress_1 | Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - o
n line 19
wordpress_1 |
wordpress_1 | Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service no
t known in - on line 19
wordpress_1 |
wordpress_1 | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known
but if I removed the volumes from mysql image, then it works fine! How can I mount the volume as I need data to be persisted.
It's actually a problem with MariaDB. You cannot mount the folder for MariaDB to the host using Docker because it presents the shared files/folders permissions to the database container as root owned with writable only by root. The solution is to use docker-compose named volumes. As stated in docker documentation:
Docker has two options for containers to store files in the host machine, so that the files are persisted even after the container stops: volumes, and bind mounts. If you’re running Docker on Linux you can also use a tmpfs mount.
What you are trying to use is the bind-mount which does not works with MariaDB. So we can use docker volume for that.
When you create a volume, it is stored within a directory on the Docker host. When you mount the volume into a container, this directory is what is mounted into the container. This is similar to the way that bind mounts work, except that volumes are managed by Docker and are isolated from the core functionality of the host machine. Volumes are stored in a part of the host filesystem which is managed by Docker(/var/lib/docker/volumes/ on Linux). So change your docker-compose file as:-
version: '2'
services:
wordpress:
image: wordpress
ports:
- 8080:80
environment:
WORDPRESS_DB_NAME: my_db
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: password
volumes:
- ./src:/var/www/html
mysql:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
i.e. use a named volume under mysql service and declare it in top level volumes key. This will tell docker-compose to create a Docker mananged volume and your MariaDB data is backed up/persisted at /var/lib/docker/volumes/_db_data/_data directory on host machine.
Also after running docker-compose up command if you do
docker volume ls
then you can see docker-compose created volume.