Two, docker mount installation and configuration mysql

First, make sure docker state has been running, and make sure the firewall is turned off (or ip and port access)

Second, download the image
1, image search

docker search mysql

Here Insert Picture Description
We see the first official mysql, but if you use docker pull mysql
will pull the latest version of the image, which is version 8.0, how to pull that specified version of it?

Need to enter the address:
https://hub.docker.com
Here Insert Picture Description
we see version 5.7, we used version 5.7
How to specify version?
pull imageName Docker: Tag
imageName: Mirror Name
tag: version number

2, image taking Pull 5.7

docker pull mysql:5.7

- View Mirror

docker images

Here Insert Picture Description
Third, start containers, and configure the mount directory

1. Create a directory to mount

mkdir -p /data/mysql5.7/logs /data/mysql5.7/conf /data/mysql5.7/data
cd /data/mysql5.7/
ll

Here Insert Picture Description
2, using a mirror to create a container

docker run -di --name=mysql-pro -p 3306:3306 -v 		/data/mysql5.7/data:/var/lib/mysql -v /data/mysql5.7/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7

Here Insert Picture Description
Parameter analysis:
Docker run: Create a container
-d: run behind the -d parameter will create a guard vessel in the background (this will not automatically logged container after container is created, if only two plus -i -t parameters, after you create will automatically go in the container).
-i: Run indicates a container
-p: mapping the port, the former is a host port, which is mapped in the port of the container. You can use multiple -p do more port mapping
-v: representing the directory mapping relationship (the former is the host directory, which is mapped to a directory on the host), you can use multiple -v do multiple directories or file mappings . Note: It is the directory for mapping, making changes on the host, and then to share the container.
-e: set environment variables, here designated root password
mysql: 5.7: image name used

Tips:
(in this way will replace /etc/mysql/conf.d/ following three files to an external mounted my.cnf file, that is to say, in this way to mount the directory, container directory consistent with the external file directory contents)

ok, run successfully. have a test
Here Insert Picture Description

success.

Fourth, look at the mount directory, look at the results

cd /data/mysql5.7/
ll

Here Insert Picture Description

The following data is data

cd data/

Here Insert Picture Description

Look at the mirror and have already initiated container

docker images
docker ps

Here Insert Picture Description

Well, is completed, the next chapter update docker redis installation and configuration mount

Published 14 original articles · won praise 2 · Views 170

Guess you like

Origin blog.csdn.net/weixin_41402056/article/details/105102161