Preface We have already installed Docker and have a brief understanding of Docker. Here are some simple steps to create a MySQL container with Docker. Without further ado, let's take a look at the detailed introduction. The steps are as follows 1. Start the docker service [root@docker ~]# systemctl start docker 2. View the image in docker [root@docker ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos/mysql-57-centos7 latest 2e4ddfafaa6f 6 months ago 445MB gogs/gogs-latest 2fb3b88053d6 6 months ago 94.2MB 3. Search for the image name you want to query [root@docker ~]# docker search mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 7854 [OK] mariadb MariaDB is a community-developed fork of MySQL… 2604 [OK] cloudfoundry/cf-mysql-ci Image used in CI of cf-mysql-release 0 [root@localhost ~]# docker pull mysql ---------------------Download the latest version by default [root@localhost ~]# docker pull mysql:5.7--------------------Download the specified version 4. Create and run a mysql container [root@docker ~]# docker run -di --name=test_mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root centos/mysql-57-centos7 d7e5f99b502a904a970026e90227e186107e3b5d0baeaa93491af12cd7317b99 run: create and run -di: create in daemon mode --name: give the container a name -p: port mapping -e: initialize the Mysql user and set the root password to root The last thing to fill in is the name of the image. If you do not specify a version, the latest one will be created by default. 5. View running containers [root@docker ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d7e5f99b502a centos/mysql-57-centos7 "container-entrypoint..." 5 seconds ago Up 4 seconds 0.0.0.0:3306->3306/tcp test_mysql 6. You can use the database tool on your computer to connect to the database in the virtual machine IP is the IP connected to the virtual machine, account: root, password: root 7. In fact, as long as you can pull a mirror, the others are similar (such as redis, mogodb, rabbitmq, etc.) Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed explanation of this reference in React
>>: mysql5.7.17 installation and configuration example on win2008R2 64-bit system
How to debug a page on iPad? When using iOS 5, you...
I won’t go into details about the theory of UDP. ...
1. First, understand the overflow-wrap attribute ...
Create a project directory mkdir php Create the f...
Red and pink, and their hexadecimal codes. #99003...
This article shares the specific code of js to im...
The operating environment of this tutorial: Windo...
Table of contents Preface 1. Configure intranet D...
During the project development yesterday, I encoun...
In Vue, we can define (register) local components...
Python connects to MySQL to modify and query data...
Preparation 1. Start the virtual machine 2. git t...
Today I made a menu button. When you move the mous...
Table of contents 1. beforeunload event 2. Unload...
Just like this effect, the method is also very si...