Install Docker and configure Alibaba Cloud Image Acceleration

content

Docker installation environment preparation:

Install Docker:

Start Docker:

Alibaba Cloud Image Acceleration:

Set startup, boot auto-start, turn off boot auto-start:


Docker installation environment preparation:

Configure a virtual machine with Internet access:

A virtual machine that can be used is required. Here, the Linux centos7 system is used to configure the docker environment.

The virtual machine configured in this way can run the docker learning environment smoothly.

Environment view:

#查看系统内核是否是3.0以上的
uname -r
#查看系统版本:
cat /etc/os-release

Install Docker:

Check out the official Docker help documentation:

https://docs.docker.com/

After opening, find the download and install it 

We installed the linux version of Docker, so we clicked on the linux version.

Click the installation of each distribution, there will be many Docker installation methods for Linux systems, such as centos, debia, etc.,

Choose according to your own version, here we choose to install the centos version of Docker.

If you have already installed Docker's virtual machine, you need to uninstall the old version of Docker:

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

If the execution command of docker has not been installed, the words do not need to delete any packages.

 After uninstalling the old version of Docker, you can start installing Docker

1. Download the required installation package:

yum install -y yum-utils

2. Set up the Docker image repository:

#官方文档的镜像仓库默认是国外的,下载速度很慢,不建议使用。
yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo #默认是国外的!!


#可以百度搜索:“docker阿里云镜像加速地址”
#这里已经为大家找好了国内的docker阿里云镜像加速地址,直接复制下面代码即可:

yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3. Install Docker related content, docker engine, etc. docker-ce means community edition, ee is enterprise edition, there are other specific versions in the official documents, you can go to the official documents to view, the official document address is above.

安装前,建议大家更新一下索引,将当前环境更新为最新:
yum makecache fast

安装docker引擎:
yum install docker-ce docker-ce-cli containerd.io

If prompted to accept the GPG key, verify that the fingerprints match  060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it. 

 After installation, start Docker

Start Docker:

systemctl start docker

This means the startup is successful. 

#安装成功后可以使用下面这句代码查看是否安装成功:
docker version

可以看到docker版本号,是社区版还是企业版,和当前安装docker的系统等详细内容

 After the installation is successful, you can test hello-world

docker run hello-world

 

 Check out this downloaded hello-world image:

#查看镜像
docker images

Understand: How to uninstall docker when you don't want to use docker? The method is also written in the official documentation.

Uninstall Docker:

卸载 Docker 引擎:
1、卸载 Docker 引擎、CLI 和 Containerd 软件包:

yum remove docker-ce docker-ce-cli containerd.io

2、主机上的映像、容器、卷或自定义配置文件不会自动删除。要删除所有映像、容器和卷:

rm -rf /var/lib/docker
rm -rf /var/lib/containerd

Alibaba Cloud Image Acceleration:

Alibaba Cloud address:

Alibaba Cloud - Going to the Cloud is Going to Alibaba Cloud Alibaba Cloud, a subsidiary of Alibaba Group, is the world's leading cloud computing and artificial intelligence technology company. Provide free trial, cloud server, cloud database, cloud security, cloud enterprise application and other cloud computing services, as well as big data, artificial intelligence services, and precise customization of scenario-based industry solutions. Free filing, 7x24 hours after-sales support, help enterprises worry-free cloud. https://www.aliyun.com/

Log in to Alibaba Cloud, find the console, click the button with three horizontal lines in the upper left corner, and find "Container Image Service". You can also search directly for the container image service in the elastic computing column.

 After entering, find the mirror accelerator, select the centOS system, and the blue section at the bottom is the command to configure mirror acceleration: everyone opens this URL with a different address for mirror acceleration, so it is recommended that you log in to Alibaba Cloud and follow the steps above to find this Accelerator, and then configure Alibaba Cloud Image Acceleration:

 There are four commands to configure the image accelerator:

#一、新建一个目录:

sudo mkdir -p /etc/docker

#二、在这个目录里daemon.json文件配置一个阿里云的镜像加速地址:

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://mjpmak3l.mirror.aliyuncs.com"]
}
EOF


#三、将镜像和docker重启:

sudo systemctl daemon-reload

sudo systemctl restart docker

Set startup, boot auto-start, turn off boot auto-start:

#启动docker
systemctl start docker

#停止docker
systemctl stop docker

#重启docker
systemctl restart docker

#设置docker开机自启
systemctl enable docker.service

#关闭开机启动
systemctl disable docker.service

#查看已启动的服务
systemctl list-units --type=service

#查看是否设置开机启动
systemctl list-unit-files | grep enable

Guess you like

Origin blog.csdn.net/weixin_53466908/article/details/124132218
Recommended