The main reference I referred is the official guide of docker link.
$ sudo apt-get update
$ sudo apt-get install linux-image-extra-$(uname -r)
$ sudo apt-get install linux-image-extra-virtual
1. Install packages to allow apt
to use a repository over HTTPS:
$ sudo apt-get install apt-transport-https \
ca-certificates \
curl \
software-properties-common
2. Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
3. Set up (add) the stable repository to the apt
package list.
amd64:
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
armhf:
$ sudo add-apt-repository \
"deb [arch=armhf] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
4. Update the apt
package index.
$ sudo apt-get update
5. Install Docker.
$ sudo apt-get install docker-ce
Notes:
You can also install it with specific version:
$ sudo apt-get install docker-ce=<VERSION>
Update docker you have installed:
$ sudo apt-get upgrade docker-ce=<VERSION>
Example:
//List the available versions. jeremy@compute1:~$ apt-cache madison docker-ce docker-ce | 17.03.1~ce-0~ubuntu-trusty | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages docker-ce | 17.03.0~ce-0~ubuntu-trusty | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages //upgrade a specific version of docker jeremy@compute1:~$ sudo apt-get upgrade docker-ce=17.03.1~ce-0~ubuntu-trusty ... Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done docker-ce is already the newest version. ...
If you encounter a error like “E: Unable to locate package docker-ce”, please run
$sudo apt-get update
6. Test the installation.
jeremy@compute1:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
7. Enjoy yourself.
If you encounter an error said “dpkg-statoverride: error: an override for ‘/boot/vmlinuz-3.13.0-119-generic’ already exists; aborting” when you run sudo apt-get install xxx
, please go here.
Reference:
https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository