環境說明
我們使用的是 CentOS 7 (64-bit)
目前,CentOS 僅發行版本中的內核支持 Docker。
Docker 運行在 CentOS 7 上,要求系統為64位、系統內核版本為 3.10 以上。
查看自己的內核:
uname -r 命令用于打印當前系統相關信息(內核版本號、硬件架構、主機名稱和操作系統類型等)。
[root@iZbp1j6nqm0rhlipfaevhhZ huayao]# uname -r
3.10.0-1062.12.1.el7.x86_64
查看版本信息:
cat /etc/os-release
[root@iZbp1j6nqm0rhlipfaevhhZ huayao]# 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"
安裝步驟
1、官網安裝參考手冊:https://docs.docker.com/engine/install/centos/
2、確定你是CentOS7及以上版本,我們已經做過了
3、yum安裝gcc相關環境(需要確保 虛擬機可以上外網 )
yum -y install gcc
yum -y install gcc-c++
4、卸載舊版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
5、安裝需要的軟件包
yum install -y yum-utils
6、設置鏡像倉庫
# 正確推薦使用國內的
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
7、更新yum軟件包索引
yum makecache fast
8、安裝 Docker CE
yum install docker-ce docker-ce-cli containerd.io
9、啟動 Docker
systemctl start docker
10、測試命令
docker version
docker run hello-world
docker images
11、卸載
systemctl stop docker
yum -y remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
阿里云鏡像加速
1、介紹:https://www.aliyun.com/product/acr
2、注冊一個屬于自己的阿里云賬戶(可復用淘寶賬號)
3、進入管理控制臺設置密碼,開通
4、查看鏡像加速器自己的
image-20230111110414857
5、配置鏡像加速,==每個人的不一樣,需要自己到阿里云去找配置==
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://qiyb9988.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
測試 HelloWorld
1、啟動hello-world
docker run hello-world