您好,登錄后才能下訂單哦!
本文小編為大家詳細介紹“Ubuntu下如何安裝Docker CE”,內容詳細,步驟清晰,細節處理妥當,希望這篇“Ubuntu下如何安裝Docker CE”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學習新知識吧。
安裝依賴
關于docker ce版本在ubuntu下安裝有如下限制
64位的os
需要ubuntu64bit的os, 確認方法如下
devops@ubuntu:~$ uname -m x86_64 devops@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 -cs artful devops@ubuntu:~$
硬件
ubuntu對docker ce的支持除了需要是64位的os之外,x86的cpu也是需要的。除了x86之外,還有如下的支持類型
armhf
s390x(ibm z)
ppc64le (ibm power)
devops@ubuntu:~$ uname -m x86_64 devops@ubuntu:~$
安裝
apt-get update
使用apt-get update更新源中的軟件列表
devops@ubuntu:~$ sudo su [sudo] password for devops: root@ubuntu:/home/devops# apt-get update hit: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... done root@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-common reading package lists... done building dependency tree reading state information... done ca-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: libcurl3 the following new packages will be installed: apt-transport-https the following packages will be upgraded: curl libcurl3 2 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] y get: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 directory locale: cannot set lc_all to default locale: no such file or directory selecting 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 - ok root@ubuntu:/home/devops#
此key的數字簽名為9dc8 5822 9fc7 dd38 854a e2d8 8d81 803c 0ebf cd88,所以可以用其最后8位進行確認
root@ubuntu:/home/devops# apt-key fingerprint 0ebfcd88 pub rsa4096 2017-02-22 [scea] 9dc8 5822 9fc7 dd38 854a e2d8 8d81 803c 0ebf cd88 uid [ unknown] docker release (ce deb) <docker@docker.com> 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 update hit: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... done root@ubuntu:/home/devops#
安裝docker-ce
root@ubuntu:/home/devops# apt-get install docker-ce reading package lists... done building dependency tree reading state information... done the following additional packages will be installed: aufs-tools cgroupfs-mount libltdl7 the following new packages will be installed: aufs-tools cgroupfs-mount docker-ce libltdl7 0 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] y get: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 directory locale: cannot set lc_all to default locale: no such file or directory selecting 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 packages root@ubuntu:/home/devops# root@ubuntu:/home/devops# apt-get install docker-ce=17.12.1~ce-0~ubuntu reading package lists... done building dependency tree reading state information... done docker-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 version client: 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/amd64 server: 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: false root@ubuntu:/home/devops#
整體信息
可以看出很多基本信息,比如存儲方式為overlay2
root@ubuntu:/home/devops# docker info containers: 0 running: 0 paused: 0 stopped: 0 images: 0 server version: 17.12.1-ce storage driver: overlay2 backing filesystem: extfs supports d_type: true native overlay diff: true logging driver: json-file cgroup driver: cgroupfs plugins: volume: local network: bridge host macvlan null overlay log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog swarm: inactive runtimes: runc default runtime: runc init binary: docker-init containerd version: 9b55aab90508bd389d7654c4baf173a981477d55 runc version: 9f9c96235cc97674e935002fc3d78361b696a69e init version: 949e6fa security options: apparmor seccomp profile: default kernel version: 4.13.0-21-generic operating system: ubuntu 17.10 ostype: linux architecture: x86_64 cpus: 1 total memory: 988.7mib name: ubuntu id: tyya:4lwb:ytha:2dnb:xbxm:nfnp:admy:vzej:2zbn:kpkw:ptml:s5a2 docker root dir: /var/lib/docker debug mode (client): false debug mode (server): false registry: https://index.docker.io/v1/ labels: experimental: false insecure registries: 127.0.0.0/8 live restore enabled: false warning: no swap limit support root@ubuntu:/home/devops#
讀到這里,這篇“Ubuntu下如何安裝Docker CE”文章已經介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領會,如果想了解更多相關內容的文章,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。