千家信息网

Ubuntu下Docker CE怎么安装

发表于:2025-01-17 作者:千家信息网编辑
千家信息网最后更新 2025年01月17日,本文小编为大家详细介绍"Ubuntu下Docker CE怎么安装",内容详细,步骤清晰,细节处理妥当,希望这篇"Ubuntu下Docker CE怎么安装"文章能帮助大家解决疑惑,下面跟着小编的思路慢慢
千家信息网最后更新 2025年01月17日Ubuntu下Docker CE怎么安装

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

安装依赖

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

64位的os

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

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

版本

支持如下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:~$ sudo su[sudo] password for devops: root@ubuntu:/home/devops# apt-get updatehit:1 http://cn.archive.ubuntu.com/ubuntu artful inrelease         get:2 http://cn.archive.ubuntu.com/ubuntu artful-updates inrelease [78.6 kb]             hit:3 http://cn.archive.ubuntu.com/ubuntu artful-backports inrelease          get:4 http://security.ubuntu.com/ubuntu artful-security inrelease [78.6 kb]get:5 http://cn.archive.ubuntu.com/ubuntu artful-updates/main i386 packages [212 kb]get:6 http://cn.archive.ubuntu.com/ubuntu artful-updates/main amd64 packages [216 kb]get:7 http://cn.archive.ubuntu.com/ubuntu artful-updates/universe i386 packages [89.0 kb]get:8 http://cn.archive.ubuntu.com/ubuntu artful-updates/universe amd64 packages [89.9 kb]fetched 764 kb in 4s (163 kb/s)                        reading package lists... doneroot@ubuntu:/home/devops#

安装所需的package

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

执行日志

root@ubuntu:/home/devops# apt-get install apt-transport-https ca-certificates curl software-properties-commonreading package lists... donebuilding dependency tree    reading state information... doneca-certificates is already the newest version (20170717).software-properties-common is already the newest version (0.96.24.17).the following additional packages will be installed: libcurl3the following new packages will be installed: apt-transport-httpsthe following packages will be upgraded: curl libcurl32 upgraded, 1 newly installed, 0 to remove and 53 not upgraded.need to get 383 kb of archives.after this operation, 247 kb of additional disk space will be used.do you want to continue? [y/n] yget:1 http://cn.archive.ubuntu.com/ubuntu artful-updates/main amd64 apt-transport-https amd64 1.5.1 [34.7 kb]get:2 http://cn.archive.ubuntu.com/ubuntu artful-updates/main amd64 curl amd64 7.55.1-1ubuntu2.3 [152 kb]               get:3 http://cn.archive.ubuntu.com/ubuntu artful-updates/main amd64 libcurl3 amd64 7.55.1-1ubuntu2.3 [196 kb]             fetched 383 kb in 14s (26.2 kb/s)                                                   perl: warning: setting locale failed.perl: warning: please check that your locale settings:  language = "en_hk:en",  lc_all = (unset),  lc_ctype = "utf-8",  lang = "en_hk.utf-8"  are supported and installed on your system.perl: warning: falling back to a fallback locale ("en_hk.utf-8").locale: cannot set lc_ctype to default locale: no such file or directorylocale: cannot set lc_all to default locale: no such file or directoryselecting previously unselected package apt-transport-https.(reading database ... 63866 files and directories currently installed.)preparing to unpack .../apt-transport-https_1.5.1_amd64.deb ...unpacking apt-transport-https (1.5.1) ...preparing to unpack .../curl_7.55.1-1ubuntu2.3_amd64.deb ...unpacking curl (7.55.1-1ubuntu2.3) over (7.55.1-1ubuntu2.2) ...preparing to unpack .../libcurl3_7.55.1-1ubuntu2.3_amd64.deb ...unpacking libcurl3:amd64 (7.55.1-1ubuntu2.3) over (7.55.1-1ubuntu2.2) ...setting up apt-transport-https (1.5.1) ...setting up libcurl3:amd64 (7.55.1-1ubuntu2.3) ...processing triggers for libc-bin (2.26-0ubuntu2) ...processing triggers for man-db (2.7.6.1-2) ...setting up curl (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 -fssl https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -okroot@ubuntu:/home/devops#

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

root@ubuntu:/home/devops# apt-key fingerprint 0ebfcd88pub  rsa4096 2017-02-22 [scea]   9dc8 5822 9fc7 dd38 854a e2d8 8d81 803c 0ebf cd88uid      [ unknown] docker release (ce deb) sub  rsa4096 2017-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-get updatehit:1 http://cn.archive.ubuntu.com/ubuntu artful inrelease            get:2 http://security.ubuntu.com/ubuntu artful-security inrelease [78.6 kb]    get:3 http://cn.archive.ubuntu.com/ubuntu artful-updates inrelease [78.6 kb]                      hit:4 http://cn.archive.ubuntu.com/ubuntu artful-backports inrelease                      get:5 https://download.docker.com/linux/ubuntu artful inrelease [51.9 kb]get:6 https://download.docker.com/linux/ubuntu artful/stable amd64 packages [1462 b]fetched 211 kb in 2s (85.8 kb/s)reading package lists... doneroot@ubuntu:/home/devops#

安装docker-ce

root@ubuntu:/home/devops# apt-get install docker-cereading package lists... donebuilding dependency tree    reading state information... donethe following additional packages will be installed: aufs-tools cgroupfs-mount libltdl7the following new packages will be installed: aufs-tools cgroupfs-mount docker-ce libltdl70 upgraded, 4 newly installed, 0 to remove and 53 not upgraded.need to get 29.9 mb of archives.after this operation, 150 mb of additional disk space will be used.do you want to continue? [y/n] yget:1 http://cn.archive.ubuntu.com/ubuntu artful-updates/universe amd64 aufs-tools amd64 1:4.1+20161219-1ubuntu0.1 [102 kb]get:2 https://download.docker.com/linux/ubuntu artful/stable amd64 docker-ce amd64 17.12.1~ce-0~ubuntu [29.8 mb]get:3 http://cn.archive.ubuntu.com/ubuntu artful/universe amd64 cgroupfs-mount all 1.4 [6320 b]get:4 http://cn.archive.ubuntu.com/ubuntu artful/main amd64 libltdl7 amd64 2.4.6-2 [38.8 kb]fetched 29.9 mb in 8s (3536 kb/s)                                                   perl: warning: setting locale failed.perl: warning: please check that your locale settings:  language = "en_hk:en",  lc_all = (unset),  lc_ctype = "utf-8",  lang = "en_hk.utf-8"  are supported and installed on your system.perl: warning: falling back to a fallback locale ("en_hk.utf-8").locale: cannot set lc_ctype to default locale: no such file or directorylocale: cannot set lc_all to default locale: no such file or directoryselecting previously unselected package aufs-tools.(reading database ... 63874 files and directories currently installed.)preparing to unpack .../aufs-tools_1%3a4.1+20161219-1ubuntu0.1_amd64.deb ...unpacking aufs-tools (1:4.1+20161219-1ubuntu0.1) ...selecting previously unselected package cgroupfs-mount.preparing to unpack .../cgroupfs-mount_1.4_all.deb ...unpacking cgroupfs-mount (1.4) ...selecting previously unselected package libltdl7:amd64.preparing to unpack .../libltdl7_2.4.6-2_amd64.deb ...unpacking libltdl7:amd64 (2.4.6-2) ...selecting previously unselected package docker-ce.preparing to unpack .../docker-ce_17.12.1~ce-0~ubuntu_amd64.deb ...unpacking docker-ce (17.12.1~ce-0~ubuntu) ...setting up aufs-tools (1:4.1+20161219-1ubuntu0.1) ...processing triggers for ureadahead (0.100.0-20) ...setting up cgroupfs-mount (1.4) ...processing triggers for libc-bin (2.26-0ubuntu2) ...processing triggers for systemd (234-2ubuntu12.1) ...setting up libltdl7:amd64 (2.4.6-2) ...processing triggers for man-db (2.7.6.1-2) ...setting up docker-ce (17.12.1~ce-0~ubuntu) ...created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.processing triggers for ureadahead (0.100.0-20) ...processing triggers for libc-bin (2.26-0ubuntu2) ...processing triggers for systemd (234-2ubuntu12.1) ...root@ubuntu:/home/devops#

指定版本安装

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

root@ubuntu:/home/devops# apt-cache madison docker-ce docker-ce | 17.12.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu artful/stable amd64 packages docker-ce | 17.12.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu artful/stable amd64 packagesroot@ubuntu:/home/devops#root@ubuntu:/home/devops# apt-get install docker-ce=17.12.1~ce-0~ubuntureading package lists... donebuilding dependency tree    reading state information... donedocker-ce is already the newest version (17.12.1~ce-0~ubuntu).0 upgraded, 0 newly installed, 0 to remove and 53 not upgraded.root@ubuntu:/home/devops#

安装后确认

版本确认

root@ubuntu:/home/devops# docker versionclient: version:  17.12.1-ce api version:  1.35 go version:  go1.9.4 git commit:  7390fc6 built: tue feb 27 22:17:53 2018 os/arch:  linux/amd64server: engine: version: 17.12.1-ce api version: 1.35 (minimum version 1.12) go version:  go1.9.4 git commit:  7390fc6 built:  tue feb 27 22:16:25 2018 os/arch: linux/amd64 experimental: falseroot@ubuntu:/home/devops#

整体信息

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

root@ubuntu:/home/devops# docker infocontainers: 0 running: 0 paused: 0 stopped: 0images: 0server version: 17.12.1-cestorage driver: overlay2 backing filesystem: extfs supports d_type: true native overlay diff: truelogging driver: json-filecgroup driver: cgroupfsplugins: volume: local network: bridge host macvlan null overlay log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslogswarm: inactiveruntimes: runcdefault runtime: runcinit binary: docker-initcontainerd version: 9b55aab90508bd389d7654c4baf173a981477d55runc version: 9f9c96235cc97674e935002fc3d78361b696a69einit version: 949e6fasecurity options: apparmor seccomp profile: defaultkernel version: 4.13.0-21-genericoperating system: ubuntu 17.10ostype: linuxarchitecture: x86_64cpus: 1total memory: 988.7mibname: ubuntuid: tyya:4lwb:ytha:2dnb:xbxm:nfnp:admy:vzej:2zbn:kpkw:ptml:s5a2docker root dir: /var/lib/dockerdebug mode (client): falsedebug mode (server): falseregistry: https://index.docker.io/v1/labels:experimental: falseinsecure registries: 127.0.0.0/8live restore enabled: falsewarning: no swap limit supportroot@ubuntu:/home/devops#

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

0