Day 02 Docker installation
1. Install Docker in CentOS7 of Huawei Cloud
1. Backup configuration files:
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
2. Install Huawei mirror source
Option One
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo # 获取华为源镜像
Option II
Modify the CentOS-Base.repo file, uncomment the line at the beginning of baseurl , and add the comment at the beginning of mirrorlist . Replace http://mirror.centos.org with https://repo.huaweicloud.com in the file , you can refer to the following command:
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
3. Execute yum clean all to clear the original yum cache.
4. Execute yum makecache (refresh the cache) or yum repolist all (check all the files that can be used by the configuration, the cache will be automatically refreshed)
5. Install Docker
yum install docker -y
systemctl start docker #启动docker
systemctl enable docker #开机启动docker
systemctl status docker #查看docker状态
Two, uninstall and reinstall
1. The old version of docker is named "docker" or "docker-engine". If these versions are installed, they need to be uninstalled first.
The content saved in "/var/lib/docker/", including pictures, disks and network configuration, will be preserved.
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate
2. Configure the software warehouse.
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 安装就可以了。
3. Install docker-ce.
sudo yum install docker-ce docker-ce-cli containerd.io
This command will always install the latest version of docker-ce, if you need to install the specified version, you can refer to the following operations:
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
4 download the software package to install
1) Via https://download.docker.com/linux/centos/7/aarch64/stable/Packages/, download the software package of the specified version.
2) Execute commands to install software packages and dependencies.
"Package.rpm" is the downloaded software package.
sudo yum install /path/to/package.rpm
3. Start the software
1) Start Docker.
sudo systemctl start docker
2) Use a hello-world image to verify that Docker is normal.
sudo docker run hello-world
The echo content is as follows:
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/
3. HUAWEI CLOUD image acceleration
1. Visit your own control center
2. Find the image acceleration address
3. Configuration file
Open docker's daemon.json configuration file /etc/dobcker/daemon.json, add the relevant image acceleration address
Enter the following command
vim /etc/dobcker/daemon.json
{
"exec-opts":["native.cgroupdriver=systemd"],
"registry-mirrors":["https://08c97a9b4300263b0fc6c013d6e65880.mirror.swr.myhuaweicloud.com"]
}
4. Restart docker
systemctl restart docker