CentOS 7.9 安裝 Docker
一、相關(guān)博客
【Docker】002-Docker安裝
https://blog.csdn.net/qq_29689343/article/details/115261766
這篇筆記不是 Markdown 寫的,改起來不方便,重新開一片記錄!
二、安裝 Docker
1、安裝 device-mapper-persistent-data 和 lvm2 兩個(gè)依賴
device-mapper-persistent-data
是Linux
下的一個(gè)存儲(chǔ)驅(qū)動(dòng),Linux
上的高級存儲(chǔ)技術(shù)。Lvm
的作用則是創(chuàng)建邏輯磁盤分區(qū)。
yum install -y yum-utils device-mapper-persistent-data lvm2
# 更新yum軟件包索引
yum makecache fast
2、添加阿里云 Docker 鏡像源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3、安裝 Docker 社區(qū)版
yum install docker-ce -y
4、啟動(dòng)
systemctl start docker
systemctl enable docker
# 查看版本
docker -v
# Docker version 24.0.2, build cb74dfc
5、運(yùn)行測試
先配置阿里云鏡像加速器
docker run hello-world
# 顯示“……Hello from Docker!……”代表運(yùn)行成功!
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
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.
(amd64)
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/
三、配置阿里云鏡像加速器
https://cr.console.aliyun.com/cn-hangzhou/instances
在 Docker
安裝完畢后,之后我們?nèi)ダ?docker
鏡像時(shí),一般默認(rèn)會(huì)去 docker
官方源拉取鏡像。但是國內(nèi)出海網(wǎng)速實(shí)在是太慢,所以選擇我們更換為 阿里云鏡像倉庫
源進(jìn)行鏡像下載加速。
登錄阿里云官網(wǎng),打開 阿里云容器鏡像服務(wù)。點(diǎn)擊左側(cè)菜單最下面的 鏡像加速器
,選擇 CentOS
(如下圖)。按照官網(wǎng)的提示執(zhí)行命令,即可更換 docker
鏡像源地址。文章來源:http://www.zghlxwxcb.cn/news/detail-497918.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-497918.html
# CentOS
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://wgsbq2gq.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
到了這里,關(guān)于CentOS 7.9 安裝 Docker的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!