怎么配置docker官方源并用yum安装docker

  • 时间:
  • 浏览:487
  • 来源:恰卡网

导读这篇文章主要介绍怎么配置docker官方源并用yum安装docker,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完! 怎么配置docker官方源并用yum安装docker 一、docker的官方安装...

这篇文章主要介绍怎么配置docker官方源并用yum安装docker,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

怎么配置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=DockerCEStable-$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=DockerCEStable-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=DockerCEStable-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=DockerCEEdge-$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=DockerCEEdge-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=DockerCEEdge-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=DockerCETest-$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=DockerCETest-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=DockerCETest-Sources
baseurl=https://download.docker.com/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

三、安装docker:

sudoyuminstalldocker-ce
Loadedplugins:fastestmirror,langpacks
Loadingmirrorspeedsfromcachedhostfile
ResolvingDependencies
-->Runningtransactioncheck
--->Packagedocker-ce.x86_640:17.03.1.ce-1.el7.centoswillbeinstalled
-->ProcessingDependency:docker-ce-selinux>=17.03.1.ce-1.el7.centosforpackage:docker-ce-17.03.1.ce-1.el7.centos.x86_64
-->Runningtransactioncheck
--->Packagedocker-ce-selinux.noarch0:17.03.1.ce-1.el7.centoswillbeinstalled
-->FinishedDependencyResolution

DependenciesResolved

=====================================================================================================================================
PackageArchVersionRepositorySize
=====================================================================================================================================
Installing:
docker-cex86_6417.03.1.ce-1.el7.centosdocker-ce-stable19M
Installingfordependencies:
docker-ce-selinuxnoarch17.03.1.ce-1.el7.centosdocker-ce-stable28k

TransactionSummary
=====================================================================================================================================
Install1Package(+1Dependentpackage)

Totaldownloadsize:19M
Installedsize:19M
Isthisok[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
total19096
-rwxrwxrwx1jianglexingjianglexing19521288May3020:05docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
-rw-r--r--1jianglexingjianglexing29108May3020:15docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
[root@workstudiodocker]#yumlocalinstall*
Loadedplugins:fastestmirror,langpacks
Examiningdocker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm:docker-ce-17.03.0.ce-1.el7.centos.x86_64
Markingdocker-ce-17.03.0.ce-1.el7.centos.x86_64.rpmtobeinstalled
Examiningdocker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm:docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch
Markingdocker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpmtobeinstalled
ResolvingDependencies
-->Runningtransactioncheck
--->Packagedocker-ce.x86_640:17.03.0.ce-1.el7.centoswillbeinstalled
--->Packagedocker-ce-selinux.noarch0:17.03.0.ce-1.el7.centoswillbeinstalled
-->FinishedDependencyResolution

DependenciesResolved

=====================================================================================================================================
PackageArchVersionRepositorySize
=====================================================================================================================================
Installing:
docker-cex86_6417.03.0.ce-1.el7.centos/docker-ce-17.03.0.ce-1.el7.centos.x86_6465M
docker-ce-selinuxnoarch17.03.0.ce-1.el7.centos/docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch43k

TransactionSummary
=====================================================================================================================================
Install2Packages

Totalsize:65M
Installedsize:65M
Isthisok[y/d/N]:y
Downloadingpackages:
Runningtransactioncheck
Runningtransactiontest
Transactiontestsucceeded
Runningtransaction
Installing:docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch1/2
setsebool:SELinuxisdisabled.
libsemanage.semanage_direct_install_info:Overridingdockermoduleatlowerpriority100withmoduleatpriority400.
Installing:docker-ce-17.03.0.ce-1.el7.centos.x86_642/2
Verifying:docker-ce-17.03.0.ce-1.el7.centos.x86_641/2
Verifying:docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch2/2

Installed:
docker-ce.x86_640:17.03.0.ce-1.el7.centosdocker-ce-selinux.noarch0:17.03.0.ce-1.el7.centos

Complete!

六、启动docker:

[root@workstudiodocker]#systemctlstartdocker
[root@workstudiodocker]#ps-ef|grepdocker
root44581120:22?00:00:00/usr/bin/dockerd
root44654458020:22?00:00:00docker-containerd-lunix:///var/run/docker/libcontainerd/docker-containerd.sock--metrics-interval=0--start-timeout2m--state-dir/var/run/docker/libcontainerd/containerd--shimdocker-containerd-shim--runtimedocker-runc
root45894333020:22pts/100:00:00grep--color=autodocker

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

[root@workstudiodocker]#dockerrunhello-world
Unabletofindimage'hello-world:latest'locally
latest:Pullingfromlibrary/hello-world
78445dd45222:Pullcomplete
Digest:sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status:Downloadednewerimageforhello-world:latest

HellofromDocker!
Thismessageshowsthatyourinstallationappearstobeworkingcorrectly.

Togeneratethismessage,Dockertookthefollowingsteps:
1.TheDockerclientcontactedtheDockerdaemon.
2.TheDockerdaemonpulledthe"hello-world"imagefromtheDockerHub.
3.TheDockerdaemoncreatedanewcontainerfromthatimagewhichrunsthe
executablethatproducestheoutputyouarecurrentlyreading.
4.TheDockerdaemonstreamedthatoutputtotheDockerclient,whichsentit
toyourterminal.

Totrysomethingmoreambitious,youcanrunanUbuntucontainerwith:
$dockerrun-itubuntubash

Shareimages,automateworkflows,andmorewithafreeDockerID:
https://cloud.docker.com/

Formoreexamplesandideas,visit:
https://docs.docker.com/engine/userguide/

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

以上是“怎么配置docker官方源并用yum安装docker”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注恰卡网行业资讯频道!

猜你喜欢

accesstoken中怎么获取用户黑名单列表

这篇文章将为大家详细讲解有关accesstoken中怎么获取用户黑名单列表,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。 公众号可登录

2021-07-29

Java中怎么利用轮询获取线程返回数据

Java中怎么利用轮询获取线程返回数据,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。 1. 多线程的特点 一般程序中

2021-07-29

XamarinEssentials中怎么获取首选项的值

这期内容当中小编将会给大家带来有关XamarinEssentials中怎么获取首选项的值,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。 XamarinEssentials教程获取首

2021-07-29

jQuery中怎么获取内容和属性

这篇文章给大家介绍jQuery 中怎么获取内容和属性,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。 jQuery - 获取内容和属性 jQuery 拥有可操作 HTML 元素和属性的强大方

2021-07-29