In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to create a MariaDB image in Docker", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to create a MariaDB image in Docker" article.
Create docker installation based on commit command [root@test01 ~] # yum install docker [root@test01 ~] # systemctl enable docker [root@test01 ~] # systemctl start docker download local image [root@test01 ~] # docker pull centos:7.4.1708 [root@test01 ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/centos 7.4.1708 3afd47092a0e 3 months ago 196.6 MB create an interactive container [root@test01 ~] # docker run-it-- name= "mysql_server" centos / bin/bash install mariadb service [root@e8126d0481d2 /] # yum-y install mariadb-server net-tools initialize mariadb [root@e8126d0481d2 /] # mysql_install_db-user=mysql background launch mariadb service [root@e8126d0481d2 /] # mysqld_safe & [1] 114 [root@e8126d0481d2 /] # 13:45:27 mysqld_ Safe Logging to'/ var/log/mariadb/mariadb.log'.180210 13:45:27 mysqld_safe Starting mysqld daemon with databases from / var/lib/mysql [root@e8126d0481d2 /] # netstat-tunplActive Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0 .0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
Create a mariadb login password and specify an ip login
[root@e8126d0481d2 /] # mysqladmin-u root password '123456' [root@e8126d0481d2 /] # mysql-u root-pEnter password:MariaDB [(none)] > show databases;MariaDB [(none)] > use mysql;MariaDB [mysql] > select Host from user where user='root';MariaDB [mysql] > grant all privileges on *. * to' root'@'%' identified by '123456' with grant option;MariaDB [mysql] > update user set password=password (' 123456') where user='root' and host='e8126d0481d2';MariaDB [mysql] > flush privileges MariaDB [mysql] > exit container login authentication [root@e8126d0481d2 /] # mysql-u root-h 172.17.0.2-pEnter password:MariaDB [(none)] > exit creation container startup script [root@e8126d0481d2 ~] # cat run.shmysqldlogin safe create image [root@test01 ~] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe8126d0481d2 centos "/ bin/bash" 11 minutes ago Exited (0) 8 seconds ago mysql_ server [root @ test01 ~] # docker commit mysql_server mariadb:1.0 create container [root@test01 ~] # docker run-d-p 13306 purl 3306 mariadb:1.0 / root/run.sh [root@test01 ~] # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESeed3e88a1261 mariadb:1.0 "mysqld_safe" 4 seconds ago Up 3 seconds 0.0.0.0 seconds 13306-> 3306/tcp romantic_hamilton host login authentication [root@test01 ~] # yum-y install mariadb [root@test01 ~] # mysql-u root- -port=13306-pMariaDB [(none)] > create directories and files based on Dockerfile creation [root@test01 ~] # mkdir mariadb_dockerfile & & cd mariadb_ dockerfiles [root @ test01 mariadb_dockerfile] # touch db_ init.sh [root @ test01 mariadb_dockerfile] # touch run.sh Editing Dockerfile and other files Dockerfile [root@test01 mariadb_dockerfile] # cat Dockerfile# uses the basic image FROM centos:7.4.1708# to add author information MAINTAINER liuxin 842887233@qq.com# Install mariadb database RUN yum-y install mariadb-server# to set environment variables Easy to manage ENV MARIADB_USER rootENV MARIADB_PASS 12345A let the container support Chinese ENV LC_ALL en_US.UTF-8# initialization database ADD db_init.sh / root/db_init.shRUN chmod 775 / root/db_init.shRUN / root/db_init.sh# export port EXPOSE 330 add startup file ADD run.sh / root/run.shRUN chmod 775 / root/run.sh# setting default startup command CMD ["/ root/run. Sh "] db_ init.sh [root @ test01 mariadb_dockerfile] # cat DBMS init.shroud installation installdb-- user=mysqlsleep 3mysqld_safe & sleep 3#mysqladmin-u" $MARIADB_USER "password" $MARIADB_PASS "mysql-e" use mysql Grant all privileges on *. * to'$MARIADB_USER'@'%' identified by'$MARIADB_PASS' with grant option; "hype $(hostname) mysql-e" use mysql; update user set password=password ('$MARIADB_PASS') where user='$MARIADB_USER' and host='$h'; "mysql-e" flush privileges "run.sh [root@test01 mariadb_dockerfile] # cat run.shrun.shrun.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx STATUS PORTS NAMES7743527ac603 liuxin/centos-mariadb:v1 "/ root/run.sh" 5 seconds ago Up 3 seconds 0.0.0.0 seconds 13306-> 3306/tcp nostalgic_mirzakhani login authentication [root@test01 mariadb_dockerfile] # mysql-uroot-h 127.0.0.1-- port=13306-pEnter password:Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 1Server version: 5.5.56-MariaDB MariaDB ServerCopyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] > exit is the content of this article on "how to create a MariaDB image in Docker". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about it, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.