先确保老版本docker都卸载了

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

tensorflow 安装_第1张图片

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

tensorflow 安装_第2张图片

更新下工具和device mapping

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

tensorflow 安装_第3张图片

tensorflow 安装_第4张图片

tensorflow 安装_第5张图片

搞定

添加docker的安装源repo

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

tensorflow 安装_第6张图片

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

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

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

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

tensorflow 安装_第7张图片

开始安装了

$ sudo yum install docker-ce

tensorflow 安装_第8张图片

49M

tensorflow 安装_第9张图片

tensorflow 安装_第10张图片

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

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

tensorflow 安装_第11张图片

启动docker

$ sudo systemctl start docker

4df824b2f4f3484f954ba800d1c43103

$ sudo docker run hello-world

感觉好像失败了

ab792b48d9264421bf1d39f1fc11c7e4

看看服务

tensorflow 安装_第12张图片

先停一下服务

tensorflow 安装_第13张图片

再起来

tensorflow 安装_第14张图片

看下端口 ,都起来了

netstat -ano | grep dock

tensorflow 安装_第15张图片

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) 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

tensorflow 安装_第16张图片

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

tensorflow 安装_第17张图片

3个小时候终于下载完成

tensorflow 安装_第18张图片

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

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

访问正常

http://192.168.209.131:8888/tree

tensorflow 安装_第19张图片

看下容器内

tensorflow 安装_第20张图片

至此安装成功