Construction of the container mysql Docker

1. Check whether the mirror on the docker have mysql, if it is not on the list did not download 

[root@holly holly]# docker images;

If you do not only see the structure

REPOSITORY  TAG  IMAGE  ID  CREATED  SIZE


2. Use the pull command to download the 5.6 version of mysql on docker  

The syntax is: docker pull Software name: version number

[root@holly holly]# docker pull mysql:5.6

 

3. Check the image has been downloaded mysql on the docker

[root@holly holly]# docker images;

If you have downloaded you will see the following list

REPOSITORY  TAG  IMAGE              ID  CREATED     SIZE
mysql       5.6   73829d7b6139  3    weeks ago    256MB

 

 

4. Run mysql image on docer, docker mysql and generates a container space, and

[root@holly holly]# docker run -d -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD='ok' 73829d7b6139

Command Description:

  • 3306 -p: 3306 : 3306 mapped to port 3306 of container port on the computer.

  • --name   represents a container from the name is mysql
  • -e MYSQL_ROOT_PASSWORD = ok: initialize the root user's password.


5. Review the operation of container

[root@holly holly]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eed6d4057455 73829d7b6139 "docker-entrypoint.s…" 14 seconds ago Up 12 seconds 0.0.0.0:3306->3306/tcp mysql

 

 

 This post is original,

Author: Wine Life

Please indicate the source: https://www.cnblogs.com/holly8/p/10994511.html

  

Guess you like

Origin www.cnblogs.com/holly8/p/10994511.html