Docker安装(CentOS版本)
Docker安装文档:链接
1、卸载系统之前的docker
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest \
docker-lastest-logrotate docker-logrotate docker-engine
2、安装依赖包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
3、设置docker repo的yum位置,告诉os去哪里安装docker
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
4、安装docker和docker-cli
sudo yum install docker-ce docker-ce-cli containerd.io
5、启动docker
sudo systemctl start docker
6、设置docker开机自启
sudo systemctl enable docker
7、配置docker镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors":["https://82m9ar63.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
Docker安装MySQL
docker常用镜像安装网址:链接
1、指定安装版本为5.7进行mysql安装
docker pull mysql:5.7
2、创建实例并启动
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=root -d mysql:5.7
-p 3306:3306
:将容器的3306端口映射到主机的3306端口-v /mydata/mysql/conf:/etc/mysql
:将配置、日志、数据文件夹挂载到主机-e MYSQL_ROOT_PASSWORD=root
:初始化root用户的密码