1.centos7安装docker:
修改虚拟机ip固定为:192.168.8.150
如下:
02 卸载之前的docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
03 安装必要的依赖
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
04 设置docker仓库 [设置阿里云镜像仓库可以先自行百度,后面课程也会有自己的docker hub讲解]
默认的国外的仓库:
sudo yum-config-manager \
--add-repo \
设置阿里云源:
先备份一下默认源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
设置阿里源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
05 安装docker
sudo yum install -y docker-ce docker-ce-cli containerd.io
06 启动docker
sudo systemctl start docker
07 测试docker安装是否成功
sudo docker run hello-world
08 配置阿里云加速
[访问下面的地址,使用自己的阿里云账号登录,查看菜单栏左下角,发现有一个镜像加速器:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors]
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://z0o173bp.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
09 体验一下:
docker pull tomcat
docker run -d --name my-tomcat -p 9090:8080 tomcat