| |
docker_mysql_install [2019/10/18 11:04] – external edit 127.0.0.1 | docker_mysql_install [2020/01/23 12:24] (current) – removed andonovj |
---|
===MySQL Configuration=== | |
Once we have docker, we can search and install any image we want: | |
| |
<sxh bash> | |
[root@localhost ~]# docker info | |
Containers: 0 | |
Running: 0 | |
Paused: 0 | |
Stopped: 0 | |
Images: 0 | |
Server Version: 18.06.0-ce | |
Storage Driver: overlay2 | |
Backing Filesystem: xfs | |
Supports d_type: true | |
Native Overlay Diff: true | |
Logging Driver: json-file | |
Cgroup Driver: cgroupfs | |
Plugins: | |
Volume: local | |
Network: bridge host macvlan null overlay | |
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog | |
Swarm: inactive | |
Runtimes: runc | |
Default Runtime: runc | |
Init Binary: docker-init | |
containerd version: d64c661f1d51c48782c9cec8fda7604785f93587 | |
runc version: 69663f0bd4b60df09991c08812a60108003fa340 | |
init version: fec3683 | |
Security Options: | |
seccomp | |
Profile: default | |
Kernel Version: 3.10.0-693.el7.x86_64 | |
Operating System: CentOS Linux 7 (Core) | |
OSType: linux | |
Architecture: x86_64 | |
CPUs: 1 | |
Total Memory: 1.796GiB | |
Name: localhost.localdomain | |
ID: JJ7T:TB2D:ODDZ:7TEB:P5QQ:TVYO:VGRK:76SO:2XXP:7Q47:2P77:KHEG | |
Docker Root Dir: /var/lib/docker | |
Debug Mode (client): false | |
Debug Mode (server): false | |
Registry: https://index.docker.io/v1/ | |
Labels: | |
Experimental: false | |
Insecure Registries: | |
127.0.0.0/8 | |
Live Restore Enabled: false | |
</sxh> | |
| |
By default the "hello-world" image is always installed and can be run as follows: | |
| |
<sxh bash> | |
[root@localhost ~]# docker run hello-world | |
Unable to find image 'hello-world:latest' locally | |
latest: Pulling from library/hello-world | |
9db2ca6ccae0: Pull complete | |
Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc | |
Status: Downloaded newer image for hello-world:latest | |
| |
Hello from Docker! | |
This message shows that your installation appears to be working correctly. | |
| |
To generate this message, Docker took the following steps: | |
1. The Docker client contacted the Docker daemon. | |
2. The Docker daemon pulled the "hello-world" image from the Docker Hub. | |
(amd64) | |
3. The Docker daemon created a new container from that image which runs the | |
executable that produces the output you are currently reading. | |
4. The Docker daemon streamed that output to the Docker client, which sent it | |
to your terminal. | |
| |
To try something more ambitious, you can run an Ubuntu container with: | |
$ docker run -it ubuntu bash | |
| |
Share images, automate workflows, and more with a free Docker ID: | |
https://hub.docker.com/ | |
| |
For more examples and ideas, visit: | |
https://docs.docker.com/engine/userguide/ | |
</sxh> | |
| |
| |
Now we can install the mysql image as follows: | |
| |
<sxh bash> | |
[root@localhost ~]# docker search mysql | |
NAME DESCRIPTION STARS OFFICIAL AUTOMATED | |
mysql MySQL is a widely used, open-source relation… 6616 [OK] | |
mariadb MariaDB is a community-developed fork of MyS… 2101 [OK] | |
mysql/mysql-server Optimized MySQL Server Docker images. Create… 485 [OK] | |
percona Percona Server is a fork of the MySQL relati… 350 [OK] | |
zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 108 [OK] | |
hypriot/rpi-mysql RPi-compatible Docker Image with Mysql 90 | |
zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server wi… 61 [OK] | |
centurylink/mysql Image containing mysql. Optimized to be link… 60 [OK] | |
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 38 [OK] | |
tutum/mysql Base docker image to run a MySQL database se… 32 | |
centos/mysql-57-centos7 MySQL 5.7 SQL database server 31 | |
mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 31 | |
schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 20 [OK] | |
bitnami/mysql Bitnami MySQL Docker Image 16 [OK] | |
zabbix/zabbix-proxy-mysql Zabbix proxy with MySQL database support 15 [OK] | |
linuxserver/mysql A Mysql container, brought to you by LinuxSe… 14 | |
centos/mysql-56-centos7 MySQL 5.6 SQL database server 8 | |
circleci/mysql MySQL is a widely used, open-source relation… 6 | |
openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6 | |
dsteinkopf/backup-all-mysql backup all DBs in a mysql server 4 [OK] | |
mysql/mysql-router MySQL Router provides transparent routing be… 2 | |
openzipkin/zipkin-mysql Mirror of https://quay.io/repository/openzip… 1 | |
cloudposse/mysql Improved `mysql` service with support for `m… 0 [OK] | |
cloudfoundry/cf-mysql-ci Image used in CI of cf-mysql-release 0 | |
ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 0 [OK] | |
[root@localhost ~]# docker pull mysql | |
Using default tag: latest | |
latest: Pulling from library/mysql | |
be8881be8156: Pull complete | |
c3995dabd1d7: Pull complete | |
</sxh> | |
| |
We can check installed images of course and see how much space they occupy: | |
| |
<sxh bash> | |
[root@localhost ~]# docker images | |
REPOSITORY TAG IMAGE ID CREATED SIZE | |
mysql latest 5dbe5b6313e1 13 hours ago 445MB | |
hello-world latest 2cb0d9787c4d 2 weeks ago 1.85kB | |
mysql/mysql-server latest 02d081b9c73e 3 months ago 300MB | |
</sxh> | |
| |
| |
We can see now, that I have installed 2 mysqls, we can initiate a new container for mysql image as follows: | |
| |
| |
<sxh bash> | |
[root@localhost ~]# docker run --name mysql2 -e MYSQL_ROOT_PASSWORD='oracle' -d mysql/mysql-server:latest | |
0cb5ef2781b253a98f67028ca7f9b2e6934ee8560718401f54bd46e07a9972d6 | |
[root@localhost ~]# | |
</sxh> | |
| |
| |
We can check the logs of the installation as follows: | |
| |
<sxh bash> | |
[root@localhost ~]# docker logs -f mysql2 | |
[Entrypoint] MySQL Docker Image 8.0.11-1.1.5 | |
[Entrypoint] Initializing database | |
2018-07-27T15:28:10.177501Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.11) initializing of server in progress as process 21 | |
mbind: Operation not permitted | |
2018-07-27T15:28:15.362667Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. | |
2018-07-27T15:28:17.111421Z 5 [Warning] [MY-010315] [Server] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:17.111452Z 5 [Warning] [MY-010315] [Server] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:17.111460Z 5 [Warning] [MY-010315] [Server] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:17.111467Z 5 [Warning] [MY-010315] [Server] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:17.111479Z 5 [Warning] [MY-010323] [Server] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:17.111484Z 5 [Warning] [MY-010323] [Server] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:17.111492Z 5 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:17.111603Z 5 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:17.111612Z 5 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:18.279696Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.11) initializing of server has completed | |
[Entrypoint] Database initialized | |
2018-07-27T15:28:21.900080Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.11) starting as process 67 | |
mbind: Operation not permitted | |
2018-07-27T15:28:22.282453Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. | |
2018-07-27T15:28:22.290888Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:22.290910Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:22.290919Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:22.290926Z 0 [Warning] [MY-010315] [Server] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:22.290942Z 0 [Warning] [MY-010323] [Server] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:22.290947Z 0 [Warning] [MY-010323] [Server] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:22.290956Z 0 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:22.292825Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:22.292838Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:22.296561Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.11' socket: '/var/lib/mysql/mysql.sock' port: 0 MySQL Community Server - GPL. | |
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it. | |
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it. | |
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it. | |
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it. | |
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it. | |
2018-07-27T15:28:24.404253Z 9 [Warning] [MY-010315] [Server] 'user' entry 'healthchecker@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:24.404283Z 9 [Warning] [MY-010315] [Server] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:24.404293Z 9 [Warning] [MY-010315] [Server] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:24.404300Z 9 [Warning] [MY-010315] [Server] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:24.404307Z 9 [Warning] [MY-010315] [Server] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:24.404320Z 9 [Warning] [MY-010323] [Server] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:24.404325Z 9 [Warning] [MY-010323] [Server] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:24.404333Z 9 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:24.404409Z 9 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:24.404417Z 9 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
| |
[Entrypoint] ignoring /docker-entrypoint-initdb.d/* | |
| |
mbind: Operation not permitted | |
2018-07-27T15:28:27.123116Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL. | |
[Entrypoint] Server shut down | |
| |
[Entrypoint] MySQL init process done. Ready for start up. | |
| |
[Entrypoint] Starting MySQL 8.0.11-1.1.5 | |
2018-07-27T15:28:27.607070Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.11) starting as process 1 | |
mbind: Operation not permitted | |
2018-07-27T15:28:28.013191Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. | |
2018-07-27T15:28:28.024200Z 0 [Warning] [MY-010315] [Server] 'user' entry 'healthchecker@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.024228Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.024237Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.024245Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.024251Z 0 [Warning] [MY-010315] [Server] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.024266Z 0 [Warning] [MY-010323] [Server] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.024271Z 0 [Warning] [MY-010323] [Server] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.024280Z 0 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.026295Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.026307Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. | |
2018-07-27T15:28:28.029599Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.11' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL. | |
</sxh> | |
| |
Finally, we can connect to the mysql, by running the mysql command from the docker: | |
| |
<sxh bash> | |
[root@localhost ~]# docker exec -it mysql2 mysql -uroot -p <- 'oracle' | |
Enter password: | |
Welcome to the MySQL monitor. Commands end with ; or \g. | |
Your MySQL connection id is 14 | |
Server version: 8.0.11 MySQL Community Server - GPL | |
| |
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. | |
| |
Oracle is a registered trademark of Oracle Corporation and/or its | |
affiliates. Other names may be trademarks of their respective | |
owners. | |
| |
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |
mysql> | |
</sxh> | |
| |