Install Docker CE for Ubuntu 18.04 LTS

qwfys200發表於2018-11-08

1 Install

1.1 Import Docker’s official GPG key

lwk@lanzhou:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
lwk@lanzhou:~$

1.2 Set up Docker’s official APT repository

lwk@lanzhou:~$ echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker-ce.list
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
lwk@lanzhou:~$ 

1.3 Update the apt package index

lwk@lanzhou:~$ sudo apt update
Get:1 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Get:2 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [2966 B]
Hit:3 https://mirrors.ustc.edu.cn/ubuntu bionic InRelease
Hit:4 https://mirrors.ustc.edu.cn/ubuntu bionic-updates InRelease
Hit:5 https://mirrors.ustc.edu.cn/ubuntu bionic-backports InRelease
Hit:6 https://mirrors.ustc.edu.cn/ubuntu bionic-security InRelease
Fetched 67.4 kB in 3s (22.8 kB/s)                 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
lwk@lanzhou:~$ 

1.4 Search the docker-ce package

lwk@lanzhou:~$ apt list|grep docker

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

cockpit-docker/bionic 164-1 all
docker/bionic 1.5-1build1 amd64
docker-ce/bionic 5:18.09.0~3-0~ubuntu-bionic amd64
docker-ce-cli/bionic 5:18.09.0~3-0~ubuntu-bionic amd64
docker-compose/bionic 1.17.1-2 all
docker-containerd/bionic 0.2.3+git+docker1.13.1~ds1-1 amd64
docker-doc/bionic 17.12.1-0ubuntu1 all
docker-registry/bionic 2.6.2~ds1-1 amd64
docker-runc/bionic 1.0.0~rc2+git+docker1.13.1~ds1-3 amd64
docker.io/bionic 17.12.1-0ubuntu1 amd64
docker2aci/bionic 0.14.0+dfsg-2 amd64
golang-docker-credential-helpers/bionic 0.5.0-2 amd64
golang-docker-dev/bionic 17.12.1-0ubuntu1 all
golang-github-appc-docker2aci-dev/bionic 0.14.0+dfsg-2 all
golang-github-containerd-docker-containerd-dev/bionic 0.2.3+git+docker1.13.1~ds1-1 all
golang-github-docker-containerd-dev/bionic 0.2.5-0ubuntu2 all
golang-github-docker-distribution-dev/bionic 2.6.2~ds1-1 all
golang-github-docker-docker-credential-helpers-dev/bionic 0.5.0-2 all
golang-github-docker-docker-dev/bionic 17.12.1-0ubuntu1 all
golang-github-docker-engine-api-dev/bionic 0.4.0-3 all
golang-github-docker-go-connections-dev/bionic 0.3.0-3 all
golang-github-docker-go-dev/bionic 0.0~git20160303.0.d30aec9-3 all
golang-github-docker-go-events-dev/bionic 0.0~git20160331.0.882f161-2 all
golang-github-docker-go-metrics-dev/bionic 0.0~git20161110.0.0f35294-1 all
golang-github-docker-go-units-dev/bionic 0.3.1+git20170127.11.9e638d3-1 all
golang-github-docker-goamz-dev/bionic 0.0~git20160206.0.f0a21f5-3 all
golang-github-docker-leadership-dev/bionic 0.1.0-1 all
golang-github-docker-libkv-dev/bionic 0.2.1-1 all
golang-github-docker-libnetwork-dev/bionic 0.8.0-dev.2+git20170202.599.45b4086-3 all
golang-github-docker-libtrust-dev/bionic 0.0~git20150526.0.9cbd2a1-3 all
golang-github-docker-notary-dev/bionic 0.1~ds1-1 all
golang-github-docker-spdystream-dev/bionic 0.0~git20151103.0.4d80814-2 all
golang-github-fsouza-go-dockerclient-dev/bionic 0.0+git20160622-3 all
golang-github-opencontainers-docker-runc-dev/bionic 1.0.0~rc2+git+docker1.13.1~ds1-3 all
golang-github-samalba-dockerclient-dev/bionic 0.0~git20160531.0.a303626-2 all
kdocker/bionic 5.0-1 amd64
libnss-docker/bionic 0.02-1 amd64
ovn-docker/bionic 2.9.0-0ubuntu1 amd64
python-docker/bionic 2.5.1-1 all
python-dockerpty/bionic 0.4.1-1 all
python-dockerpycreds/bionic 0.2.1-1 all
python3-docker/bionic 2.5.1-1 all
python3-dockerpty/bionic 0.4.1-1 all
python3-dockerpycreds/bionic 0.2.1-1 all
ruby-docker-api/bionic 1.22.2-1 all
systemd-docker/bionic 0.2.1+dfsg-2 amd64
vim-syntax-docker/bionic 17.12.1-0ubuntu1 all
lwk@lanzhou:~$

1.5 Install the docker-ce package

lwk@lanzhou:~$ sudo apt 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 containerd.io docker-ce-cli libltdl7 pigz
The following NEW packages will be installed:
  aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli libltdl7 pigz
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 50.6 MB of archives.
After this operation, 243 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 pigz amd64 2.4-1 [57.4 kB]
Get:2 https://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 aufs-tools amd64 1:4.9+20170918-1ubuntu1 [104 kB]
Get:3 https://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 cgroupfs-mount all 1.4 [6320 B]
Get:4 https://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libltdl7 amd64 2.4.6-2 [38.8 kB]
Get:5 https://download.docker.com/linux/ubuntu bionic/stable amd64 containerd.io amd64 1.2.0~rc.2-1 [19.9 MB]
Get:6 https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-ce-cli amd64 5:18.09.0~3-0~ubuntu-bionic [13.1 MB]                                                                                                                 
Get:7 https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-ce amd64 5:18.09.0~3-0~ubuntu-bionic [17.4 MB]                                                                                                                     
Fetched 50.6 MB in 16s (3080 kB/s)                                                                                                                                                                                                           
Selecting previously unselected package pigz.
(Reading database ... 106495 files and directories currently installed.)
Preparing to unpack .../0-pigz_2.4-1_amd64.deb ...
Unpacking pigz (2.4-1) ...
Selecting previously unselected package aufs-tools.
Preparing to unpack .../1-aufs-tools_1%3a4.9+20170918-1ubuntu1_amd64.deb ...
Unpacking aufs-tools (1:4.9+20170918-1ubuntu1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../2-cgroupfs-mount_1.4_all.deb ...
Unpacking cgroupfs-mount (1.4) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../3-containerd.io_1.2.0~rc.2-1_amd64.deb ...
Unpacking containerd.io (1.2.0~rc.2-1) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack .../4-libltdl7_2.4.6-2_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-2) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../5-docker-ce-cli_5%3a18.09.0~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce-cli (5:18.09.0~3-0~ubuntu-bionic) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../6-docker-ce_5%3a18.09.0~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce (5:18.09.0~3-0~ubuntu-bionic) ...
Setting up aufs-tools (1:4.9+20170918-1ubuntu1) ...
Setting up containerd.io (1.2.0~rc.2-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Processing triggers for ureadahead (0.100.0-20) ...
Setting up cgroupfs-mount (1.4) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.4) ...
Setting up libltdl7:amd64 (2.4.6-2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up docker-ce-cli (5:18.09.0~3-0~ubuntu-bionic) ...
Setting up pigz (2.4-1) ...
Setting up docker-ce (5:18.09.0~3-0~ubuntu-bionic) ...
update-alternatives: using /usr/bin/dockerd-ce to provide /usr/bin/dockerd (dockerd) in auto mode
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
lwk@lanzhou:~$ 

1.6 Verify

  Verify that Docker CE is installed correctly by running the hello-world image.


1.7 use docker group

lwk@lanzhou:~$ sudo usermod -aG docker lwk

2 Reference

相關文章