安装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运行环境。