Ubuntu下Docker CE的安装

2019-01-16 20:41:14王冬梅

添加GPG key

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

命令:curl -fsSL https://download.docker.com/linux/ubuntu/gpg | 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] https://download.docker.com/linux/ubuntu $(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#