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