cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo # 获取华为源镜像
修改CentOS-Base.repo文件,取消baseurl开头的行的注释,并增加mirrorlist开头的行的注释。将文件中的http://mirror.centos.org替换成https://repo.huaweicloud.com,可以参考如下命令:
sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s/mirrorlist=http/#mirrorlist=http/g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s@http://mirror.centos.org@https://repo.huaweicloud.com@g" /etc/yum.repos.d/CentOS-Base.repo
yum install docker -y
systemctl start docker #启动docker
systemctl enable docker #开机启动docker
systemctl status docker #查看docker状态
保存在“/var/lib/docker/”中的内容,包括图片、磁盘和网络配置等都会保留下来。
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager: command not found
这个是因为系统默认没有安装这个命令,这个命令在yum-utils 包里,可以通过命令yum -y install yum-utils 安装就可以了。
sudo yum install docker-ce docker-ce-cli containerd.io
这个命令总是会安装最新版本的docker-ce,如果需要安装指定版本的可以参考下面的操作:
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
1)通过https://download.docker.com/linux/centos/7/aarch64/stable/Packages/,下载指定版本的软件包。
2)执行命令安装软件包及依赖。
“package.rpm”为下载的软件包。
sudo yum install /path/to/package.rpm
3. 启动软件
1)启动Docker。
sudo systemctl start docker
2)使用一个hello-world镜像验证Docker是否正常。
sudo docker run hello-world
回显内容如下:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
3b4173355427: Pull complete
Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(arm64v8)
3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
打开docker的daemon.json配置文件/etc/dobcker/daemon.json,添加相关镜像加速地址
输入以下命令
vim /etc/dobcker/daemon.json
{
"exec-opts":["native.cgroupdriver=systemd"],
"registry-mirrors":["https://08c97a9b4300263b0fc6c013d6e65880.mirror.swr.myhuaweicloud.com"]
}
systemctl restart docker