1、在Linux上安装Docker容器
cd /etc/yum.repos.d/
curl -O https://download.docker.com/linux/centos/docker-ce.repo
sed -i 's/$releasever/8/g' docker-ce.repo
yum install -y docker-ce
2、修改Docker默认镜像仓库,然后启动Docker容器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://dockerproxy.com",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://ccr.ccs.tencentyun.com"
]
}
EOF
systemctl start docker
systemctl enable docker
systemctl status docker
3、安装Mysql
docker pull mysql
4、启动Mysql
docker run --name dataplatform --restart=always --privileged=true \
-v /usr/local/mysql/data:/var/lib/mysql \
-v /usr/local/mysql/conf.d:/etc/mysql/conf.d \
-v /etc/localtime:/etc/localtime:ro \
-e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql:latest
5、查看Mysql运行状态
docker ps -a
6、设置容器启动时自动启动Mysql
docker update dataplatform --restart=always
7、重启Mysql实例
docker restart dataplatform