安装docker
移除旧的版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
安装一些必要的系统工具:
yum install -y yum-utils device-mapper-persistent-data lvm2
添加软件源信息
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新 yum 缓存:
yum makecache fast
安装 Docker-ce:
yum -y install docker-ce
systemctl start docker # 启动
systemctl enable docker # 开机启动
配置镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://7sdd7nbu.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
docker 容器服务开机启动
docker update 容器ID --restart=always
docker 导出导入镜像
docker save -o xxx.tar imagesid ##-o:指定保存的镜像的名字;rocketmq.tar:保存到本地的镜像名称;rocketmq:镜像名字,通过"docker images"查看
docker import - xxx:v1.xx.x < xxxx