Running on a CentOS 7 server
Yum Install Docker
When you are finished installing Docker, run
Service Docker start starts Docker
Due to the company's server connection Dockerhub has been some problems, it is estimated that GFW caused, so can only download a domestic mirror
https://hub.tenxcloud.com/you can go to the speed cloud to search for the image you need
I chose one of the tallest MySQL images of star
Use the following command to download the MySQL image to a local
Docker Pull Index.tenxcloud.com/tenxcloud/mysql
When you are finished, you can use Docker images to view the image locally
650) this.width=650; "title=" Tmp53af "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "tmp53af" src= "Http://s3.51cto.com/wyfs02/M02/8D/B5/wKiom1imsHGT-OTzAADtZwRTKnE634.png" height= "97 "/>
Once the image has finished downloading, it is now possible to pull the Docker image up locally
There are also detailed commands to start Docker on the speed cloud to view
Refer to this URL
Https://hub.tenxcloud.com/repos/tenxcloud/mysql
But the boot command written on the tutorial is
Docker run-d-P 3306:3306 tutum/mysql
But it can't be done directly,
The specific command is as follows, you need to change the mirror address to the address you previously displayed after the local docker images
Because, this image on the speed cloud is Tutum/mysql's domestic mirror, if we use it locally,
Can not directly carry out this (speed cloud is also lazy enough, it is estimated that directly copied dockerhub come over, also do not comment)
Docker run-d-P 3306:3306 index.tenxcloud.com/tenxcloud/mysql
Explain the command,-D is run in the background,-P is to map the 3306 port in the container to the 3306 port of the Docker host, and if your Docker host IP is 192.168.0.1 Then you access the MySQL Docker service running on 192.168.0.1 from other servers, just need to access 192.168.0.1:3306.
After the run is complete, you can use Docker PS to view the running status of Docker
650) this.width=650; "title=" M7jx55 ' 9gx6@ (%uv77rq77w "style=" border-top:0px;border-right:0px;border-bottom:0px; border-left:0px; "border=" 0 "alt=" m7jx55 ' 9gx6@ (%uv77rq77w "src=" http://s3.51cto.com/wyfs02/M00/8D/B2/ Wkiol1imshhtchlzaacxxm0vt40739.png "height="/>
You can see that the mirror using index.tenxcloud.com/tenxcloud/mysql started a container with a Contatner ID of 20c1b8a3ad3a (please ignore the boot time, this container I am directly from my test environment), Names was randomly given to the system.
Now that the container is up, we can connect to the MySQL service externally using MySQL workbench, or go inside the container and use the MySQL command to do something
We first use the Docker EXEC command to enter into this container, the specific command format is as follows
Docker Exec–it Container Id/bin/bash
Where it refers to enabling interactive mode,/bin/bash is entered after using bash
650) this.width=650; "title=" Tmp39f2 "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "tmp39f2" src= "Http://s3.51cto.com/wyfs02/M02/8D/B3/wKioL1imsHPD3uiYAACqO3Npu7Q049.png" height= "68 "/>
After entering the container, the following terminal prompt is displayed, where @ is the container ID number, and most of the Linux commands can be executed in the container.
650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "image" Src= "Http://s3.51cto.com/wyfs02/M00/8D/B3/wKioL1imsHOC_I0WAAATcPAR23k578.png" height= "27"/ >
Run the MySQL command
650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "image" Src= "Http://s3.51cto.com/wyfs02/M00/8D/B5/wKiom1imsHSD3u6YAAF1cpfz0PM083.png" height= "277" />
Run show DATABASES;
650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "image" Src= "http://s3.51cto.com/wyfs02/M01/8D/B3/wKioL1imsHSC4mNcAACyl6wJQ8I368.png" height= "232" />
You can see the libraries created in this MySQL server.
Let's try it again. Connect to the database using MySQL Workbench
Install MySQL Workbench First, use MySQL Workbench connection MySQL will find, do not know what MySQL admin account is
We'll go back to Https://hub.tenxcloud.com/repos/tenxcloud/mysql and write the initial account details.
The user name is admin, but the password is random. We need to check this password through Docker logs.
650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "image" Src= "Http://s3.51cto.com/wyfs02/M00/8D/B3/wKioL1imsHXS9NlRAAEez3S0f5c904.png" height= "273" />
We use the Docker logs container ID number to view the log of the container and the password to appear in the log.
650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "image" Src= "Http://s3.51cto.com/wyfs02/M00/8D/B5/wKiom1imsHeglQXeAAKOohM4vXE917.png" height= "347" />
We use the password found in admin and log to connect MySQL library
The built-in tables can be completed in a graphical interface.
The Docker version of MySQL is basically ready to use.
650) this.width=650; "title=" tmp6727 "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "tmp6727" src= "Http://s3.51cto.com/wyfs02/M01/8D/B3/wKioL1imsHnRklnRAAJch_0M9Kw738.png" height= " 543 "/>
MySQL Learning 2 using Docker to build a MySQL service