Ubuntu16.04 安装 docker

安装docker首先要须要一台宿主机, 我目前用VMvare下安装的Ubuntu16.04系统为宿主机,进行docker安装测试。mysql

ubuntu安装时选的中文环境,生成的sources.list里面的源url主要是:cn.archive.ubuntu.com,这个能够从国内服务器下载一些信息,相对较快。linux

目前最新docker分为 docker-ce和docker-ee两个版本,其中ce为社区版免费的,ee为商业版商用的,目前测试用ce版本。sql

主要安装过程参考官方文档步骤,以下:docker

一、首次更新ubuntuubuntu

$ sudo apt-get update

二、安装linux-image-extra-* 包,这一步不可少,否则后面安装docker会从国外网址下载,通常被墙的下载不了, 也就安装不成功tomcat

$ sudo apt-get install \
    linux-image-extra-$(uname -r) \
    linux-image-extra-virtual

三、安装httpsbash

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

四、安装GPG key服务器

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

五、验证 key的 fingerprint 为 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.app

$ sudo apt-key fingerprint 0EBFCD88

上面命令输出信息为:curl

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

六、安装仓库

$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

七、再次更新

$ sudo apt-get update

八、安装docker-ce,这一步我没有用国内源,因此下载很慢,下次发国内源的安装

$ sudo apt-get install docker-ce

九、上面执行完毕,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运行环境。