Centos7, for example
The installation of a docker
#1. Uninstall the earlier version
yum remove docker \
>docker-client \ > docker-client-latest \ > docker-common \ > docker-latest \ > docker-latest-logrotate \ > docker-logrotate \ > docker-engine
#2. Required installation package
yum install -y yum-utils
#3. Set the repository for the image
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
#The above methods are not recommended because they are imported by default
#Recommended to use domestic
yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#Update package Index
yum makecache fast
#4. Install Docker Docker-CE community edition and EE is enterprise editionYum install docker-ce docker-ce-cli containerd. IO # yum install docker-ce-cli containerd. IO #
#5. Start the docker
systemctl start docker
#6. Use docker Version to check whether the installation is successful
docker version
#7. Test
docker run hello-world
Copy the code
The installation of mysql8
docker search mysql
docker pull mysql
docker images
cd /opt
mkdir mysql_docker
cd mysql_docker
echo $PWD
Copy the code
run
docker run --name mysqlserver -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d -i -p 3306:3306 mysql:latest
Copy the code
docker exec -it mysqlserver bash
Copy the code
Enabling Remote Access
use mysql;
select host,user from user;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
Copy the code
Mysql 5.7
Docker pull mysql: 5.7Copy the code
Create the instance and start it
-e set mysql parameters -d sudo docker run -p 3306:3306 --name mysql \ -v /mydata/mysql/log:/var/log/mysql \ -v /mydata/mysql/data:/var/lib/mysql \ -v /mydata/mysql/conf:/etc/mysql \ -e MYSQL_ROOT_PASSWORD=123456 \ -d mysql:5.7 #### -v Mount the corresponding file to the host -e Initialize the corresponding -p container port mapped to the host portCopy the code
MySQL configuration
Vi/mydata/mysql/conf/my CNF to create and modify the fileCopy the code
[client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake skip-name-resolveCopy the code
docker restart mysql
Copy the code
redis
Docker pull Redis :6.0 Create an instance and start it
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
Copy the code
The startup maps to the corresponding folder, followed by \ for newline
docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf
Copy the code
6.0
Docker run -p 6379:6379 --name redis6.0 \ -v /mydata/redis/data:/data \ -v / mydata/redis/conf/redis. Conf: / etc/redis/redis conf \ - d redis: 6.0 redis server/etc/redis/redis. ConfCopy the code
Connect to docker exec it redis redis-cli using redis imageCopy the code
Persistent default appendonly on is not enabled
vim /mydata/redis/conf/redis.conf
Copy the code
Insert the following
appendonly yes
Copy the code