安装 Docker(使用国内源)

一、安装Docker-ce

1、下载阿里云的repo源

root@localhost \~\]# **yum install yum-utils -y** **\&\&** **yum-config-manager --add-repo** [https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo](https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo "https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo")**\&\&** **yum makecache** # 尝试列出 docker-ce 的版本 \[root@localhost \~\]# **yum list docker-ce --showduplicates \| sort -r** 2、安装 Docker-ce \[root@localhost \~\]# **yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y** 4、启动Docker \[root@localhost \~\]# **systemctl restart docker \&\& systemctl enable docker** **\&\&** **docker --version** Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service. Docker version 27.3.1, build ce12230 # 验证安装 \[root@localhost \~\]# **docker version** Client: Docker Engine - Community Version: 27.3.1 API version: 1.47 Go version: go1.22.7 Git commit: ce12230 Built: Fri Sep 20 11:42:48 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 27.3.1 API version: 1.47 (minimum version 1.24) Go version: go1.22.7 Git commit: 41ca978 Built: Fri Sep 20 11:41:09 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.23 GitCommit: 57f17b0a6295a39009d861b89e3b3b87b005ca27 runc: Version: 1.1.14 GitCommit: v1.1.14-0-g2c9f560 docker-init: Version: 0.19.0 GitCommit: de40ad0 ## 二、配置仓库 1、新建目录,存放daemon.json文件 \[root@localhost \~\]# **mkdir -p /etc/docker** 2、写入docker仓库地址到daemon.json文件 \[root@localhost \~\]# **tee /etc/docker/daemon.json \<\<-'EOF'** **{** **"registry-mirrors": \["** [Docker Hub Search](https://docker.fxxk.dedyn.io "Docker Hub Search")**"\]** **}** **EOF** 注: 1)、网上说的修改成阿里的仓库地址已不可用,官方调整说明: \[root@localhost \~\]# curl [https://x3eaedgw.mirror.aliyuncs.com](https://x3eaedgw.mirror.aliyuncs.com "https://x3eaedgw.mirror.aliyuncs.com") This request is forbidden. Please proceed to [https://help.aliyun.com/zh/acr/product-overview/product-change-acr-mirror-accelerator-function-adjustment-announcement](https://help.aliyun.com/zh/acr/product-overview/product-change-acr-mirror-accelerator-function-adjustment-announcement "https://help.aliyun.com/zh/acr/product-overview/product-change-acr-mirror-accelerator-function-adjustment-announcement") to view the announcement. 2 )、这里提供的 **r** **egistry-mirrors** 如果有天也不可用,修改一个可用的就可以了。 3、重启docker服务 \[root@localhost \~\]# **systemctl daemon-reload \&\& systemctl restart docker** 4、拉取镜像/运行容器 成功 \[root@localhost \~\]# **docker pull hello-world** Using default tag: latest latest: Pulling from library/hello-world c1ec31eb5944: Pull complete Digest: sha256:305243c734571da2d100c8c8b3c3167a098cab6049c9a5b066b6021a60fcb966 Status: Downloaded newer image for hello-world:latest docker.io/library/hello-world:latest \[root@localhost \~\]# **docker run hello-world** 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/](https://hub.docker.com/ "https://hub.docker.com/") For more examples and ideas, visit: [Get started \| Docker Docs](https://docs.docker.com/get-started/ "Get started | Docker Docs")

相关推荐
MilesShi2 小时前
从 scheduler_tick 到上下文切换:深入解析 Linux 内核的 TIF_NEED_RESCHED 标志设置流程
linux·运维·单片机
真上帝的左手3 小时前
十一、容器化 vs 虚拟化-Kubernetes(K8s)
云原生·容器·kubernetes
落日漫游3 小时前
K8s ConfigMap配置管理全解析
云原生·容器·kubernetes
我真的是大笨蛋3 小时前
K8S-Pod(下)
java·笔记·云原生·容器·kubernetes
紫金修道5 小时前
k8s的容器操作指令
云原生·容器·kubernetes
方渐鸿5 小时前
【2024】k8s集群 图文详细 部署安装使用(两万字)
java·运维·容器·kubernetes·k8s·运维开发·持续部署
喝杯白开水!5 小时前
K8s中的控制器DaemonSet、StatefulSet、Job、CronJob、Server发现、健康检查、存储卷(PV),相关知识总结
云原生·容器·kubernetes
晓衣5 小时前
2025“獬豸杯”全国电子数据取证竞赛-k8s服务器取证wp
服务器·经验分享·程序人生·网络安全·容器·kubernetes·学习方法
学亮编程手记5 小时前
K8S v1.33 版本主要新特性介绍
java·容器·kubernetes
我爱云计算5 小时前
K8S详解(5万字详细教程)
linux·运维·云原生·容器·kubernetes