一、初始化centos系统脚本
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config
systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
firewall-cmd --state
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all && yum makecache
yum update -y
二、国内源docker安装脚本
curl -sSL https://get.daocloud.io/docker | sh -s -- "--mirror" "Aliyun"
mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["https://6m7d428u.mirror.aliyuncs.com"],
"dns": ["114.114.114.114"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
EOF
systemctl enable docker && systemctl daemon-reload && systemctl restart docker
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
三、拉取MySQL镜像
MySQL镜像地址(选择自己需要安装的版本):
https://hub.docker.com/_/mysql?tab=tags&page=1&ordering=last_updated
拉取命令:docker pull mysql:5.7.33
四、启动容器
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7.33
可以打下 docker images 看到当前拉取的镜像
然后执行 docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7.33
mysql-test 是这个新建的容器的名称 -p 3306:3306 是将容器内mysql默认要使用的3306的端口映射到当前虚拟机的3306端口上
MYSQL_ROOT_PASSWORD=123456 是为安装的mysql5.7.33设置默认的root账户的密码 mysql:5.7.33是当前容器要用到的镜像的名称
本文暂时没有评论,来添加一个吧(●'◡'●)