Docker deployment and mysql installation

1. Install docker

1. The system kernel should be greater than 3.10, responsible for the need to update the kernel

#uname -r View the kernel version (3.10 and above do not need to perform the following steps)

 

 

 

#Import the public key of the ELRepo warehouse rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

#Install the yum source rpm of the ELRepo warehouse -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

#Install the latest version of the kernel yum --enablerepo=elrepo-kernel install kernel-ml After the kernel is installed, it needs to be set to the default startup option and restarted to take effect.#View all available kernels on the system: sudo awk -F\' ' $1=="menuentry "{print i++": "$2}' /etc/grub2.cfg #Set the latest installed kernel as the default kernel grub2-set-default 0

#Generate the grub configuration file and restart grub2-mkconfig -o /boot/grub2/grub.cfg

#Verify uname -r

#Remove the RPM package of the old kernel $yum remove kernel-3.10.0-514.el7.x86_64 \ 2. Install docker #Install docker yum install docker 2. Start docker service

#After the installation is complete, use the following command to start the docker service and set it to start at boot:

service docker start

chkconfig docker on

3. Use docker to install mysql as an example:

#Pull the latest version of mysql

docker pull mysql:latest

#View all pulled mirrors

docker images

Take screenshots of each command. I am too tired and don't want to take screenshots one by one.

 

 

#Run mysql container

docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql

Here are a few points to note: 1. If mysql is already running locally, port 3306 will conflict, you can turn off the local mysql with systemctl stop mysqld;

2. The container that has been run, regardless of whether it is successful or not, will remind that the container already exists and needs to be removed. Here we first docker ps -a (unlike docker ps, the former is owned by all, and the latter is how many containers have already been run , And then find the corresponding cid, docker rm cid remove the container, and then start

You can see that mysql is running:

 

 

Guess you like

Origin blog.csdn.net/cvbnjmkl/article/details/108802522