環境:Ubuntu Trusty 14.04 (LTS)
前提條件:
Docker requires a 64-bit installation regardless of your Ubuntu version.
Additionally, your kernel must be 3.10 at minimum.
1.檢查Linux系統內核。
$ uname -r
3.13.0-24-generic
2.更新系統源。
$ sudo apt-get update
3.更新Https和CA證書。
ensure that APT works with the https method, and that CA certificates are installed.
$ sudo apt-get install apt-transport-https ca-certificates
4.添加新的GPG Key。
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
5.添加Docker源。
$ echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
6.更新系統源。
$ sudo apt-get update
7.校驗APT是否正在拉取爭取的源。
Each entry should have the URL https://apt.dockerproject.org/repo/
$ apt-cache policy docker-engine
docker-engine:
Installed: 1.12.2-0~trusty
Candidate: 1.12.2-0~trusty
Version table:
*** 1.12.2-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
100 /var/lib/dpkg/status
1.12.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.12.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.11.2-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.11.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
8.安裝linux-image-extra-*包。
$ sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
9.更新系統源。
$ sudo apt-get update
10.安裝Docker。
$ sudo apt-get install docker-engine
11.啟動Docker Daemon。
$ sudo service docker start
12.校驗Docker是否安裝正確。
$ sudo docker run hello-world
This command downloads a test image and runs it in a container.
When the container runs, it prints an informational message. Then, it exits.
卸載步驟:
1. 卸載Docker package
$ sudo apt-get purge docker-engine
2.卸載Docker package以及依賴
$ sudo apt-get autoremove --purge docker-engine
3.刪除所有相關的Image、Container和Volume
$ rm -rf /var/lib/docker
參考:https://docs.docker.com/engine/installation/linux/ubuntulinux/