先确保老版本docker都卸载了

$ sudo yum remove docker \ docker-common \ docker-selinux \ docker-engine

7b444d703aef46158971bdb76c24b915

好久没开虚拟机了,我先更新下repo

e7a6f3b3f3684da88304c49c366b5151

更新下工具和device mapping

$ sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2

5c47e18d56fb4293a7cb8d44cad105cb

140adbc4873f4077a2e3d53855b72bfe

eaffe3a747a64cbeb41d5fc82a3758a7

搞定

添加docker的安装源repo

$ sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo

b4481cd6cc844f57afe1c1d2bbb92a5b

可以把配置管理的测试模式打开

$ sudo yum-config-manager --enable docker-ce-edge

$ sudo yum-config-manager --enable docker-ce-test

$ sudo yum-config-manager --disable docker-ce-edge

f53ed249456c407a9b39f03b90d3ca4d

开始安装了

$ sudo yum install docker-ce

0a17d1115d9f4ab2b4886291ba3ad8f2

49M

98dca576741d4ce8952239b9d71ed1b8

e83bcbd34c824e4590600794ed3eb492

看看GPG key对不对,如果你是第一次安装

060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35

9a9a54da518c48adb71ace152e5d9ad7

启动docker

$ sudo systemctl start docker

4df824b2f4f3484f954ba800d1c43103

$ sudo docker run hello-world

感觉好像失败了

ab792b48d9264421bf1d39f1fc11c7e4

看看服务

f10b2c55049846bba08b3bcdd8690807

先停一下服务

820733e889ac49239cff966a0c589c53

再起来

b8836b9230c44d5cad8a2af2c16f8e7c

看下端口 ,都起来了

netstat -ano | grep dock

c8b285d6ca2740f08e201017628eb01a

docker run hello-world

7fed19eb01a74c0b9d9795944dac5b47

还是有报错,错误看起来是停止的时候出错,正常情况下应该是如下信息,我先略过了

$ 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: ...(snipped)...

看下docker 容器是否有hello world 运行

docker ps -ls

4aa6f2794b7c432092c877e0e29a2610

总结,可以看出docker的命令一般为 

[sudo] docker [subcommand] [flags] [arguments] 

centos 的很多资源在国内被墙,忍无可忍换了ubunto,搞定hello world

SET UP THE REPOSITORY

Update the apt package index:

$ sudo apt-get update

Install packages to allow apt to use a repository over HTTPS:

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

Add Docker’s official GPG key:

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

Verify that you now have the key with the fingerprint9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

$ 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

INSTALL DOCKER CE

Update the apt package index.

$ sudo apt-get update

Install the latest version of Docker CE, or go to the next step to install a specific version. Any existing installation of Docker is replaced.

$ sudo apt-get install docker-ce

f8b86f8d1279485781007753cae151fc

跑一个tensorflow在docker容器中试试看,本地没有,下载中

90dbed553f4543faa1d933544eddd7cc

3个小时候终于下载完成

d4b2f9e5c547468493d8f61aad4a373c

localhost 访问失败,本地连接怎么可能有错,转念一想是虚拟机有ip的

http://localhost:8888/?token=3ebe80b2f599ab18fbb52da208407e11f0fed6aa738feeba

访问正常

http://192.168.209.131:8888/tree

5d4d777d43284307a956217fc8e78bb7

看下容器内

b203ada5eb4e4698872af8d3cd822dbc

至此安装成功