安裝docker首先要需要一台宿主機, 我目前用VMvare下安裝的Ubuntu16.04系統為宿主機,進行docker安裝測試。
ubuntu安裝時選的中文環境,生成的sources.list里面的源url主要是:cn.archive.ubuntu.com,這個可以從國內服務器下載一些信息,相對較快。
目前最新docker分為 docker-ce和docker-ee兩個版本,其中ce為社區版免費的,ee為商業版商用的,目前測試用ce版本。
主要安裝過程參考官方文檔步驟,如下:
1、首次更新ubuntu
$ sudo apt-get update
2、安裝linux-image-extra-*
包,這一步不可少,不然后面安裝docker會從國外網址下載,一般被牆的下載不了, 也就安裝不成功
$ sudo apt-get install \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
3、安裝https
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
4、安裝GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
5、驗證 key的 fingerprint 為 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
.
$ sudo apt-key fingerprint 0EBFCD88
上面命令輸出信息為:
pub 4096R/0EBFCD88 2017-02-22 Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid Docker Release (CE deb) <docker@docker.com> sub 4096R/F273FCD8 2017-02-22
6、安裝倉庫
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
7、再次更新
$ sudo apt-get update
8、安裝docker-ce,這一步我沒有用國內源,所以下載很慢,下次發國內源的安裝
$ sudo apt-get install docker-ce
9、上面執行完畢,docker應該算是安裝完畢了,可以輸入下面命令測試是否成功
$ sudo docker run hello-world
如果成功,則輸出如下信息:
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
至此, docker的安裝算是完成了,下面文章將創建容器並搭建jdk-tomcat-mysql的WEB運行環境。