Ubuntu下如何安装Docker CE

服务器   2024年03月13日 21:37  

本文小编为大家详细介绍“Ubuntu下如何安装Docker ”,内容详细,步骤清晰,细节处理妥当,希望这篇“Ubuntu下如何安装Docker ”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

安装依赖

关于docker ce版本在ubuntu下安装有如下限制

64位的os

需要ubuntu64bit的os, 确认方法如下

devops@:~$uname-mx86_64devops@:~$

版本

支持如下ubuntu的版本

artful 17.10

xenial 16.04 (lts)

trusty 14.04 (lts)

注意:其中artful 17.10只支持docker ce17.11 edge以及以后版本,因为artful本身也是在2017年10月发行的过渡版本

发行代码的确认方式,比如artful

devops@ubuntu:~$lsb_release-csartfuldevops@ubuntu:~$

硬件

ubuntu对docker ce的支持除了需要是64位的os之外,x86的cpu也是需要的。除了x86之外,还有如下的支持类型

armhf

s390x(ibm z)

ppc64le (ibm power)

devops@ubuntu:~$uname-mx86_64devops@ubuntu:~$

安装

apt-get update

使用apt-get update更新源中的软件列表

devops@ubuntu:~$sudosu[sudo]passwordfordevops:root@ubuntu:/home/devops#apt-getupdatehit:1http://cn.archive.ubuntu.com/ubuntuartfulinreleaseget:2http://cn.archive.ubuntu.com/ubuntuartful-updatesinrelease[78.6kb]hit:3http://cn.archive.ubuntu.com/ubuntuartful-backportsinreleaseget:4http://security.ubuntu.com/ubuntuartful-securityinrelease[78.6kb]get:5http://cn.archive.ubuntu.com/ubuntuartful-updates/maini386packages[212kb]get:6http://cn.archive.ubuntu.com/ubuntuartful-updates/mainamd64packages[216kb]get:7http://cn.archive.ubuntu.com/ubuntuartful-updates/universei386packages[89.0kb]get:8http://cn.archive.ubuntu.com/ubuntuartful-updates/universeamd64packages[89.9kb]fetched764kbin4s(163kb/s)readingpackagelists...doneroot@ubuntu:/home/devops#

安装所需的package

命令:apt-get install apt-transport-https ca-certificates curl software-properties-common

执行日志

root@ubuntu:/home/devops#apt-getinstallapt-transport-httpsca-certificatescurlsoftware-properties-commonreadingpackagelists...donebuildingdependencytreereadingstateinformation...doneca-certificatesisalreadythenewestversion(20170717).software-properties-commonisalreadythenewestversion(0.96.24.17).thefollowingadditionalpackageswillbeinstalled:libcurl3thefollowingnewpackageswillbeinstalled:apt-transport-httpsthefollowingpackageswillbeupgraded:curllibcurl32upgraded,1newlyinstalled,0toremoveand53notupgraded.needtoget383kbofarchives.afterthisoperation,247kbofadditionaldiskspacewillbeused.doyouwanttocontinue?[y/n]yget:1http://cn.archive.ubuntu.com/ubuntuartful-updates/mainamd64apt-transport-httpsamd641.5.1[34.7kb]get:2http://cn.archive.ubuntu.com/ubuntuartful-updates/mainamd64curlamd647.55.1-1ubuntu2.3[152kb]get:3http://cn.archive.ubuntu.com/ubuntuartful-updates/mainamd64libcurl3amd647.55.1-1ubuntu2.3[196kb]fetched383kbin14s(26.2kb/s)perl:warning:settinglocalefailed.perl:warning:pleasecheckthatyourlocalesettings:language="en_hk:en",lc_all=(unset),lc_ctype="utf-8",lang="en_hk.utf-8"aresupportedandinstalledonyoursystem.perl:warning:fallingbacktoafallbacklocale("en_hk.utf-8").locale:cannotsetlc_ctypetodefaultlocale:nosuchfileordirectorylocale:cannotsetlc_alltodefaultlocale:nosuchfileordirectoryselectingpreviouslyunselectedpackageapt-transport-https.(readingdatabase...63866filesanddirectoriescurrentlyinstalled.)preparingtounpack.../apt-transport-https_1.5.1_amd64.deb...unpackingapt-transport-https(1.5.1)...preparingtounpack.../curl_7.55.1-1ubuntu2.3_amd64.deb...unpackingcurl(7.55.1-1ubuntu2.3)over(7.55.1-1ubuntu2.2)...preparingtounpack.../libcurl3_7.55.1-1ubuntu2.3_amd64.deb...unpackinglibcurl3:amd64(7.55.1-1ubuntu2.3)over(7.55.1-1ubuntu2.2)...settingupapt-transport-https(1.5.1)...settinguplibcurl3:amd64(7.55.1-1ubuntu2.3)...processingtriggersforlibc-bin(2.26-0ubuntu2)...processingtriggersforman-db(2.7.6.1-2)...settingupcurl(7.55.1-1ubuntu2.3)...root@ubuntu:/home/devops#

添加gpg key

使用如下命令添加docker官方的gpg key,

命令:curl -fssl | sudo apt-key add -

执行日志

root@ubuntu:/home/devops#curl-fsslhttps://download..com/linux/ubuntu/gpg|sudoapt-keyadd-okroot@ubuntu:/home/devops#

此key的数字签名为9dc8 5822 9fc7 dd38 854a e2d8 8d81 803c 0ebf cd88,所以可以用其最后8位进行确认

root@ubuntu:/home/devops#apt-keyfingerprint0ebfcd88pubrsa40962017-02-22[scea]9dc858229fc7dd38854ae2d88d81803c0ebfcd88uid[unknown]dockerrelease(cedeb)<docker@docker.com>subrsa40962017-02-22[s]root@ubuntu:/home/devops#

设定stable源仓库

使用如下命令设定x86安装类型的stable源仓库

命令:add-apt-repository “deb [arch=amd64] $(lsb_release -cs) stable”

如果是其他类型的化,对应关系参看如下,将上述命令中的arch=amd64进行替换即可

执行日志:

root@ubuntu:/home/devops#add-apt-repository"deb[arch=amd64]https://download.docker.com/linux/ubuntu$(lsb_release-cs)stable"root@ubuntu:/home/devops#

apt-get update

再次使用apt-get update更新源中的软件列表

root@ubuntu:/home/devops#apt-getupdatehit:1http://cn.archive.ubuntu.com/ubuntuartfulinreleaseget:2http://security.ubuntu.com/ubuntuartful-securityinrelease[78.6kb]get:3http://cn.archive.ubuntu.com/ubuntuartful-updatesinrelease[78.6kb]hit:4http://cn.archive.ubuntu.com/ubuntuartful-backportsinreleaseget:5https://download.docker.com/linux/ubuntuartfulinrelease[51.9kb]get:6https://download.docker.com/linux/ubuntuartful/stableamd64packages[1462b]fetched211kbin2s(85.8kb/s)readingpackagelists...doneroot@ubuntu:/home/devops#

安装docker-ce

root@ubuntu:/home/devops#apt-getinstalldocker-cereadingpackagelists...donebuildingdependencytreereadingstateinformation...donethefollowingadditionalpackageswillbeinstalled:aufs-toolscgroupfs-mountlibltdl7thefollowingnewpackageswillbeinstalled:aufs-toolscgroupfs-mountdocker-celibltdl70upgraded,4newlyinstalled,0toremoveand53notupgraded.needtoget29.9mbofarchives.afterthisoperation,150mbofadditionaldiskspacewillbeused.doyouwanttocontinue?[y/n]yget:1http://cn.archive.ubuntu.com/ubuntuartful-updates/universeamd64aufs-toolsamd641:4.1+20161219-1ubuntu0.1[102kb]get:2https://download.docker.com/linux/ubuntuartful/stableamd64docker-ceamd6417.12.1~ce-0~ubuntu[29.8mb]get:3http://cn.archive.ubuntu.com/ubuntuartful/universeamd64cgroupfs-mountall1.4[6320b]get:4http://cn.archive.ubuntu.com/ubuntuartful/mainamd64libltdl7amd642.4.6-2[38.8kb]fetched29.9mbin8s(3536kb/s)perl:warning:settinglocalefailed.perl:warning:pleasecheckthatyourlocalesettings:language="en_hk:en",lc_all=(unset),lc_ctype="utf-8",lang="en_hk.utf-8"aresupportedandinstalledonyoursystem.perl:warning:fallingbacktoafallbacklocale("en_hk.utf-8").locale:cannotsetlc_ctypetodefaultlocale:nosuchfileordirectorylocale:cannotsetlc_alltodefaultlocale:nosuchfileordirectoryselectingpreviouslyunselectedpackageaufs-tools.(readingdatabase...63874filesanddirectoriescurrentlyinstalled.)preparingtounpack.../aufs-tools_1%3a4.1+20161219-1ubuntu0.1_amd64.deb...unpackingaufs-tools(1:4.1+20161219-1ubuntu0.1)...selectingpreviouslyunselectedpackagecgroupfs-mount.preparingtounpack.../cgroupfs-mount_1.4_all.deb...unpackingcgroupfs-mount(1.4)...selectingpreviouslyunselectedpackagelibltdl7:amd64.preparingtounpack.../libltdl7_2.4.6-2_amd64.deb...unpackinglibltdl7:amd64(2.4.6-2)...selectingpreviouslyunselectedpackagedocker-ce.preparingtounpack.../docker-ce_17.12.1~ce-0~ubuntu_amd64.deb...unpackingdocker-ce(17.12.1~ce-0~ubuntu)...settingupaufs-tools(1:4.1+20161219-1ubuntu0.1)...processingtriggersforureadahead(0.100.0-20)...settingupcgroupfs-mount(1.4)...processingtriggersforlibc-bin(2.26-0ubuntu2)...processingtriggersforsystemd(234-2ubuntu12.1)...settinguplibltdl7:amd64(2.4.6-2)...processingtriggersforman-db(2.7.6.1-2)...settingupdocker-ce(17.12.1~ce-0~ubuntu)...createdsymlink/etc/systemd/system/multi-user.target.wants/docker.service→/lib/systemd/system/docker.service.createdsymlink/etc/systemd/system/sockets.target.wants/docker.socket→/lib/systemd/system/docker.socket.processingtriggersforureadahead(0.100.0-20)...processingtriggersforlibc-bin(2.26-0ubuntu2)...processingtriggersforsystemd(234-2ubuntu12.1)...root@ubuntu:/home/devops#

指定版本安装

如果希望指定版本方式安装,则在安装时需要指定docker-ce=17.12.1~ce-0~ubuntu版本方式即可

root@ubuntu:/home/devops#apt-cachemadisondocker-cedocker-ce|17.12.1~ce-0~ubuntu|https://download.docker.com/linux/ubuntuartful/stableamd64packagesdocker-ce|17.12.0~ce-0~ubuntu|https://download.docker.com/linux/ubuntuartful/stableamd64packagesroot@ubuntu:/home/devops#root@ubuntu:/home/devops#apt-getinstalldocker-ce=17.12.1~ce-0~ubuntureadingpackagelists...donebuildingdependencytreereadingstateinformation...donedocker-ceisalreadythenewestversion(17.12.1~ce-0~ubuntu).0upgraded,0newlyinstalled,0toremoveand53notupgraded.root@ubuntu:/home/devops#

安装后确认

版本确认

root@ubuntu:/home/devops#dockerversionclient:version:17.12.1-ceapiversion:1.35goversion:go1.9.4gitcommit:7390fc6built:tuefeb2722:17:532018os/arch:linux/amd64server:engine:version:17.12.1-ceapiversion:1.35(minimumversion1.12)goversion:go1.9.4gitcommit:7390fc6built:tuefeb2722:16:252018os/arch:linux/amd64experimental:falseroot@ubuntu:/home/devops#

整体信息

可以看出很多基本信息,比如存储方式为overlay2

root@ubuntu:/home/devops#dockerinfocontainers:0running:0paused:0stopped:0images:0serverversion:17.12.1-cestoragedriver:overlay2backingfilesystem:extfssupportsd_type:truenativeoverlaydiff:trueloggingdriver:json-filecgroupdriver:cgroupfsplugins:volume:localnetwork:bridgehostmacvlannulloverlaylog:awslogsfluentdgcplogsgelfjournaldjson-filelogentriessplunksyslogswarm:inactiveruntimes:runcdefaultruntime:runcinitbinary:docker-initcontainerdversion:9b55aab90508bd389d7654c4baf173a981477d55runcversion:9f9c96235cc97674e935002fc3d78361b696a69einitversion:949e6fasecurityoptions:apparmorseccompprofile:defaultkernelversion:4.13.0-21-genericoperatingsystem:ubuntu17.10ostype:linuxarchitecture:x86_64cpus:1totalmemory:988.7mibname:ubuntuid:tyya:4lwb:ytha:2dnb:xbxm:nfnp:admy:vzej:2zbn:kpkw:ptml:s5a2dockerrootdir:/var/lib/dockerdebugmode(client):falsedebugmode(server):falseregistry:https://index.docker.io/v1/labels:experimental:falseinsecureregistries:127.0.0.0/8liverestoreenabled:falsewarning:noswaplimitsupportroot@ubuntu:/home/devops#

读到这里,这篇“Ubuntu下如何安装Docker CE”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注行业资讯频道。

域名注册
购买VPS主机

您或许对下面这些文章有兴趣:                    本月吐槽辛苦排行榜

看贴要回贴有N种理由!看帖不回贴的后果你懂得的!


评论内容 (*必填):
(Ctrl + Enter提交)   

部落快速搜索栏

各类专题梳理

网站导航栏

X
返回顶部