如何配置docker官方源并用yum安装docker

发布时间 - 2026-01-11 02:23:59    点击率:

本文介绍了如何配置docker官方源并用yum安装docker ,分享给大家,希望对各位有帮助

一、docker的官方安装文档:

https://docs.docker.com/engine/installation/linux/centos/

由docker给的文档可以看出它也只是去配置了一个docker的yum源、然后就通过这个源来安装docker了;在这个文档下我们采用手工配置

的方式

二、配置一个docker用的源:

1、为docker 增加一个新的yum配置文件;touch /etc/yum.repos.d/docker.repo

touch /etc/yum.repos.d/docker.repo

2、docker.repo的内容如下

[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=0 #我把这里设置成了0、说明我信任了这个源,不对它的rpm进行检察
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://download.docker.com/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://download.docker.com/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

三、安装docker:

sudo yum install docker-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.03.1.ce-1.el7.centos will be installed
--> Processing Dependency: docker-ce-selinux >= 17.03.1.ce-1.el7.centos for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-ce-selinux.noarch 0:17.03.1.ce-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
 Package             Arch         Version                Repository            Size
=====================================================================================================================================
Installing:
 docker-ce            x86_64        17.03.1.ce-1.el7.centos        docker-ce-stable         19 M
Installing for dependencies:
 docker-ce-selinux        noarch        17.03.1.ce-1.el7.centos        docker-ce-stable         28 k

Transaction Summary
=====================================================================================================================================
Install 1 Package (+1 Dependent package)

Total download size: 19 M
Installed size: 19 M
Is this ok [y/d/N]: y

四、直接下载rpm包的方式来安装:

1、我在安装docker的时候发现下载的速度只有3kB/s 然而文件大小有19M;就在我感觉安装无望的时候、我机智的想到了自己直接把rpm下载下来

看了下docker.repo 、发现centos7的源地址是 https://download.docker.com/linux/centos/7/$basearch/stable 所以我只要去

https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

用迅雷(我是会员有加速)把rpm包下载下来就行了

下载如下文件:

docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm

五、安装docker: 

ll
total 19096
-rwxrwxrwx 1 jianglexing jianglexing 19521288 May 30 20:05 docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
-rw-r--r-- 1 jianglexing jianglexing  29108 May 30 20:15 docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
[root@workstudio docker]# yum localinstall *
Loaded plugins: fastestmirror, langpacks
Examining docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm: docker-ce-17.03.0.ce-1.el7.centos.x86_64
Marking docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm to be installed
Examining docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm: docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch
Marking docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.03.0.ce-1.el7.centos will be installed
---> Package docker-ce-selinux.noarch 0:17.03.0.ce-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
 Package         Arch     Version             Repository                        Size
=====================================================================================================================================
Installing:
 docker-ce        x86_64    17.03.0.ce-1.el7.centos     /docker-ce-17.03.0.ce-1.el7.centos.x86_64        65 M
 docker-ce-selinux    noarch    17.03.0.ce-1.el7.centos     /docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch    43 k

Transaction Summary
=====================================================================================================================================
Install 2 Packages

Total size: 65 M
Installed size: 65 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch                                 1/2 
setsebool: SELinux is disabled.
libsemanage.semanage_direct_install_info: Overriding docker module at lower priority 100 with module at priority 400.
 Installing : docker-ce-17.03.0.ce-1.el7.centos.x86_64                                     2/2 
 Verifying : docker-ce-17.03.0.ce-1.el7.centos.x86_64                                     1/2 
 Verifying : docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch                                 2/2 

Installed:
 docker-ce.x86_64 0:17.03.0.ce-1.el7.centos          docker-ce-selinux.noarch 0:17.03.0.ce-1.el7.centos          

Complete!

六、启动docker: 

[root@workstudio docker]# systemctl start docker
[root@workstudio docker]# ps -ef | grep docker
root    4458   1 1 20:22 ?    00:00:00 /usr/bin/dockerd
root    4465  4458 0 20:22 ?    00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root    4589  4333 0 20:22 pts/1  00:00:00 grep --color=auto docker

七、测试docker是否能成功运行: 

[root@workstudio docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete 
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
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.
 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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

如下是第一次运行hello-world 这个docker-image 由于它还不存在于本地、所以要下载它、这可能要用一点时间!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。


# docker  # yum  #   # yum安装docker  # 配置docker官方源  # 如何解决安装docker的yum工具时报错问题  # 超级简洁的使用YUM安装docker  # 使用YUM 安装 docker的方法步骤  # CentOS7中配置Docker的yum源并安装使用详解  # 详解CentOS7用阿里云Docker Yum源在线安装Docker 17.03.2  # yum下载rpm以及相关依赖的方式离线安装docker  # yum下载docker安装包安装到离线机器的实例代码详解  # docker安装  # yum安装失败解决方案  # 阿里云镜像安装过程  # 文档  # 我是  # 我在  # 成了  # 在我  # 看了  # 在这个  # 我只  # 要去  # 我把  # 给大家  # 要用  # 不存在  # 可以看出  # 它也  # 它还  # 这可  # 是否能  # 配置文件  # 大家多多 


相关栏目: 【 网站优化151355 】 【 网络推广146373 】 【 网络技术251813 】 【 AI营销90571


相关推荐: Laravel Livewire是什么_使用Laravel Livewire构建动态前端界面  如何自定义建站之星模板颜色并下载新样式?  企业在线网站设计制作流程,想建设一个属于自己的企业网站,该如何去做?  如何快速完成中国万网建站详细流程?  Laravel如何配置任务调度?(Cron Job示例)  Laravel Pest测试框架怎么用_从PHPUnit转向Pest的Laravel测试教程  如何用低价快速搭建高质量网站?  网站视频制作书签怎么做,ie浏览器怎么将网站固定在书签工具栏?  iOS UIView常见属性方法小结  怎么制作一个起泡网,水泡粪全漏粪育肥舍冬季氨气超过25ppm,可以有哪些措施降低舍内氨气水平?  今日头条微视频如何找选题 今日头条微视频找选题技巧【指南】  简历在线制作网站免费版,如何创建个人简历?  Windows10怎样连接蓝牙设备_Windows10蓝牙连接步骤【教程】  laravel怎么为API路由添加签名中间件保护_laravel API路由签名中间件保护方法  Laravel如何使用集合(Collections)进行数据处理_Laravel Collection常用方法与技巧  Angular 表单中正确绑定输入值以确保提交与验证正常工作  Laravel怎么生成URL_Laravel路由命名与URL生成函数详解  手机网站制作平台,手机靓号代理商怎么制作属于自己的手机靓号网站?  深圳网站制作培训,深圳哪些招聘网站比较好?  javascript如何操作浏览器历史记录_怎样实现无刷新导航  Laravel如何将应用部署到生产服务器_Laravel生产环境部署流程  ai格式如何转html_将AI设计稿转换为HTML页面流程【页面】  如何为不同团队 ID 动态生成多个独立按钮  网站制作报价单模板图片,小松挖机官方网站报价?  Laravel如何使用Gate和Policy进行权限控制_Laravel权限判定与策略规则配置  rsync同步时出现rsync: failed to set times on “xxxx”: Operation not permitted  Claude怎样写结构化提示词_Claude结构化提示词写法【教程】  Laravel队列任务超时怎么办_Laravel Queue Timeout设置详解  laravel怎么配置和使用PHP-FPM来优化性能_laravel PHP-FPM配置与性能优化方法  想要更高端的建设网站,这些原则一定要坚持!  Laravel中间件如何使用_Laravel自定义中间件实现权限控制  如何快速搭建自助建站会员专属系统?  Laravel如何发送邮件_Laravel Mailables构建与发送邮件的简明教程  个人网站制作流程图片大全,个人网站如何注销?  Laravel与Inertia.js怎么结合_使用Laravel和Inertia构建现代单页应用  大同网页,大同瑞慈医院官网?  Laravel如何使用Blade组件和插槽?(Component代码示例)  矢量图网站制作软件,用千图网的一张矢量图做公司app首页,该网站并未说明版权等问题,这样做算不算侵权?应该如何解决?  家族网站制作贴纸教程视频,用豆子做粘帖画怎么制作?  微信h5制作网站有哪些,免费微信H5页面制作工具?  Laravel怎么使用artisan命令缓存配置和视图  Laravel如何使用软删除(Soft Deletes)功能_Eloquent软删除与数据恢复方法  Android中AutoCompleteTextView自动提示  图片制作网站免费软件,有没有免费的网站或软件可以将图片批量转为A4大小的pdf?  如何使用 jQuery 正确渲染 Instagram 风格的标签列表  Laravel如何处理和验证JSON类型的数据库字段  如何用AI一键生成爆款短视频文案?小红书AI文案写作指令【教程】  如何在云虚拟主机上快速搭建个人网站?  Laravel如何自定义错误页面(404, 500)?(代码示例)  Laravel如何构建RESTful API_Laravel标准化API接口开发指南