
Docker安装
查看Linux系统版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| # 查看系统内核版本 uname -r # 查看当前系统信息 cat /etc/os-release NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"
|
安装
官方文档:https://docs.docker.com/engine/install/centos/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| # 1. 卸载旧的版本 yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine # 2. 需要的安装包 yum install -y yum-utils # 3. 设置镜像仓库 yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo # 默认使用国外的仓库 yum-config-manager \ --add-repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 推荐安装 # 4. 安装Docker引擎 docker-ce 社区版 yum makecache fast # 更新下载的索引,下载最新资源 yum install -y docker-ce docker-ce-cli containerd.io # 5. 启动Docker systemctl start docker # 6. 验证Docker是否安装成功 docker run hello-world # 7. 查看Docker所安装的镜像 docker images
|
测试运行Docker是否安装成功
执行docker version
:

可以看到所安装docker的详细信息,安装成功!

查看Docker所安装的镜像
执行docker images
:

刚刚下载的hello-world就在这些镜像中
配置阿里云镜像加速
登录阿里云https://www.aliyun.com/。
选择容器镜像服务ACR。



配置使用
1 2 3 4 5 6 7 8 9 10 11
| sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://3hrrgjog.mirror.aliyuncs.com"] } EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
|

到此处配置成功
卸载Docker
1 2 3 4
| # 卸载Docker yum remove docker-ce docker-ce-cli containerd.io # 删除Docker路径下的文件 rm -rf /var/lib/docker
|