一、开始安装

第一步:   由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本:

$ sudo apt-get remove docker docker-engine docker-ce docker.io

第二步、更新apt包索引:

$ sudo apt-get update

第三步、  安装以下包以使apt可以通过HTTPS使用存储库(repository):

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

第四步、 添加Docker官方的GPG密钥:

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

第五步: 使用下面的命令来设置stable存储库:

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

第六步:     再更新一下apt包索引:

$ sudo apt-get update

第七步:    安装最新版本的Docker CE:

$ sudo apt-get install -y docker-ce

在生产系统上,可能会需要应该安装一个特定版本的Docker CE,而不是总是使用最新版本:

第八步:列出可用的版本:
            $ apt-cache madison docker-ce
选择要安装的特定版本,第二列是版本字符串,第三列是存储库名称,它指示包来自哪个存储库,以及扩展它的稳定性级别。要安装一个特定的版本,将版本字符串附加到包名中,并通过等号(=)分隔它们:

$ sudo apt-get install docker-ce=<VERSION> 

验证docker

    查看docker服务是否启动:

$ systemctl status docker

    1

    若未启动,则启动docker服务:

$ sudo systemctl start docker

    1

    经典的hello world:

$ sudo docker run hello-world 


二、运行报错:解决方案

昨天在使用docker 时,将 image 文件从仓库抓取到本地一直报错,经过尝试,终于得以解决。

错误信息如下:

[root@archlinux ~]# docker image pull library/hello-world
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: dial tcp 52.20.146.203:443: i/o timeout

或者:

[root@archlinux quanxj]# docker image pull library/hello-world
Using default tag: latest
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
error pulling image configuration: Get https://registry-1.docker.io/v2/library/hello-world/blobs/sha256:f2a91732366c0332ccd7afd2a5c4ff2b9af81f549370f7a19acd460f87686bc7: dial tcp 35.169.231.249:443: i/o timeout

解决方法如下:
第一步:通过dig @114.114.114.114 registry-1.docker.io找到可用IP

[root@archlinux ~]# dig @114.114.114.114 registry-1.docker.io
; <<>> DiG 9.12.0 <<>> @114.114.114.114 registry-1.docker.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37534
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 88f87a15f4ca45dc (echoed)
;; QUESTION SECTION:
;registry-1.docker.io. IN A
;; ANSWER SECTION:
registry-1.docker.io. 30 IN A 34.200.28.105
registry-1.docker.io. 30 IN A 52.22.181.254
registry-1.docker.io. 30 IN A 35.169.231.249
registry-1.docker.io. 30 IN A 52.5.185.86
registry-1.docker.io. 30 IN A 54.164.230.151
registry-1.docker.io. 30 IN A 34.200.90.16
registry-1.docker.io. 30 IN A 52.20.146.203
registry-1.docker.io. 30 IN A 52.206.156.207
;; Query time: 116 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: 四 3月 08 09:27:12 CST 2018
;; MSG SIZE rcvd: 189

第二步:尝试修改/etc/hosts强制docker.io相关的域名解析到其它可用IP

vim /etc/hosts
  • 1

添加一个可用IP:

52.5.185.86 registry-1.docker.io
  • 1

保存之后重试:

[root@archlinux quanxj]# docker image pull library/hello-world
Using default tag: latest
latest: Pulling from library/hello-world
ca4f61b1923c: Already exists
Digest: sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b9559b27182d3fa80ce3f7
Status: Downloaded newer image for hello-world:latest

验证:

[root@archlinux quanxj]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest f2a91732366c 3 months ago 1.85kB 三、如果还不行,则用如下方法: [root@teddy /]# docker search ubuntu
Error response from daemon: Get https://index.docker.io/v1/search?q=ubuntu: read tcp 52.200.132.201:443: i/o timeout docker在中国已经有了仓库:https://www.docker-cn.com/registry-mirror 根据上面网站提供的修改方法。 进入/etc/docker 查看有没有 daemon.json。这是docker默认的配置文件。 如果没有新建touch daemon.json,如果有,则修改。 [root@teddy docker]# vi daemon.json
{
  "registry-mirrors": ["https://registry.docker-cn.com"]
} 保存退出。 重启docker服务 service docker restart 成功! [root@teddy docker]# docker search ubuntu
NAME                               DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubuntu                             The official build of ubuntu.                   3732      [OK]       
ansible/ubuntu-ansible            Ansible on ubuntu                              102                  [OK]
jdeathe/ubuntu-ssh                 ubuntu-6 6.9 x86_64 / ubuntu 7.4.1708 x8...   87                   [OK]
tutum/ubuntu                       Simple ubuntu docker image with SSH access      33                   
imagine10255/ubuntu6-lnmp-php56    ubuntu6-lnmp-php56                              31                   [OK]
gluster/gluster-ubuntu             Official GlusterFS Image [ ubuntu +  Glu...   20                   [OK]
kinogmt/ubuntu-ssh                 ubuntu with SSH                                 17                   [OK]
ubuntu/php-56-ubuntu              Platform for building and running PHP 5.6 ...   10                   
openshift/base-ubuntu             A ubuntu derived base image for Source-To...   10                   
ubuntu/python-35-ubuntu           Platform for building and running Python 3...   9                    
openshift/mysql-55-ubuntu         DEPRECATED: A ubuntu based MySQL v5.5 ima...   6                    
openshift/jenkins-2-ubuntu        A ubuntu based Jenkins v2.x image for use...   5                    
openshift/ruby-20-ubuntu          DEPRECATED: A ubuntu based Ruby v2.0 imag...   3                    
darksheer/ubuntu                   Base ubuntu Image -- Updated hourly             3                    [OK]
indigo/ubuntu-maven                Vanilla ubuntu 7 with Oracle Java Developm...   1                    [OK]
openshift/php-55-ubuntu           DEPRECATED: A ubuntu based PHP v5.5 image...   1                    
pivotaldata/ubuntu-gpdb-dev        ubuntu image for GPDB development. Tag nam...   1                    
pivotaldata/ubuntu-mingw           Using the mingw toolchain to cross-compile...   1                    
miko2u/ubuntu6                     ubuntu6 日本語環境                                   1                    [OK]
blacklabelops/ubuntu               ubuntu Base Image! Built and Updates Daily!     1                    [OK]
smartentry/ubuntu                  ubuntu with smartentry                          0                    [OK]
pivotaldata/ubuntu                 Base ubuntu, freshened up a little with a ...   0                    
openshift/wildfly-101-ubuntu     A ubuntu based WildFly v10.1 image for us...   0                    
jameseckersall/sonarr-ubuntu       Sonarr on ubuntu 7                              0                    [OK]
pivotaldata/ubuntu-gcc-toolchain   ubuntu with a toolchain, but unaffiliated ...   0                    
[root@teddy docker]#
												

ubuntu安装docker{ubuntu16.04下安装docker}的更多相关文章

  1. docker学习笔记(一)—— ubuntu16.04下安装docker

    docker学习笔记(一)—— ubuntu16.04下安装docker 原创 2018年03月01日 14:53:00 标签: docker / ubuntu 1682 本文开发环境为Ubuntu ...

  2. Ubuntu16.04下安装数据库oracle客户端

    在Ubuntu16.04下安装oracle数据库客户端,使Django项目连接到远程Oracle数据库. 1.下载oracle客户端安装包: 进入官网http://www.oracle.com/tec ...

  3. Ubuntu16.04下安装redis

    Ubuntu16.04下安装redis 保证网络畅通,选定好下载工作路径,执行以下命令下载redis-3.2.6: sudo wget http://download.redis.io/release ...

  4. ubuntu16.04下安装artoolkit5

    目前对AR技术的常见理解就是CV(Computer Vision)+CG(Computer Graphic).CV的方法很多,简单些比如FREAK+ICP(ARToolKit中的NFT),复杂些就是S ...

  5. Ubuntu16.04下安装多版本cuda和cudnn

    Ubuntu16.04下安装多版本cuda和cudnn 原文 https://blog.csdn.net/tunhuzhuang1836/article/details/79545625 前言 因为之 ...

  6. Ubuntu16.04下安装texlive

    Ubuntu 16.04下安装texlive的步骤如下: 1.下载texlive 打开终端输入:sudo apt-get install texlive-full  #下载这一过程会持续10-20分钟 ...

  7. Ubuntu16.04下安装Hadoop

    一.记录理由 刚开始只是想要学习怎么使用Hive的.想着安装应该很简单,没想到花了整整一天的时间来安装,为了避免下次犯同样的错误,特此记录. 二.安装Hadoop 网上教你怎么安装Hadoop的文章有 ...

  8. Ubuntu16.04下安装googlechrome flash 插件和安装网易云音乐

    一.ubuntu 16.04 下安装完后发现 flash无法播放没有安装flash插件因为 Adobe Flash 不再支持 linux Google 便开发了PepperFlashPlayer来替代 ...

  9. Ubuntu16.04下安装搭配Python3.6相关配置软件方法

    1 安装Python3.6.4 此处推荐直接安装Anaconda3,来实现Python3.6.4的环境配置. Anaconda3下载链接:https://www.anaconda.com/downlo ...

随机推荐

  1. [六]JavaIO之 ByteArrayInputStream与ByteArrayOutputStream

      功能简介   ByteArrayInputStream 和 ByteArrayOutputStream 提供了针对于字符数组 byte [] 的标准的IO操作方式     ByteArrayInp ...

  2. springboot情操陶冶-web配置(五)

    本文讲讲mvc的异常处理机制,方便查阅以及编写合理的异常响应方式 入口例子 很简单,根据之前的文章,我们只需要复写WebMvcConfigurer接口的异常添加方法即可,如下 1.创建简单的异常处理类 ...

  3. 基本 SQL 之数据库及表管理

    上篇文章,我们基于『数据库』做了一个宏观上的介绍,你应当了解到数据库是在何种背景下,为了解决什么样的问题而诞生的,以及在具体实现下又可以划分哪些中类型. 非关系型数据库的种类很多,我们会在后续的篇章中 ...

  4. Joda-Time开源库

    Joda-Time是一个面向 Java™ 平台的易于使用的开源时间日期库. 依赖 <dependency> <groupId>joda-time</groupId> ...

  5. 服务器配置https

    服务器配置https 第一步.申请证书 这个网上有很多申请方法,不论你是阿里云还是腾讯云都有自带的申请途经,这里就不再赘述. 第二步.进行配置(linux) 1.在tomcat的conf目录下创建新的 ...

  6. Linux 安装composer

    wget https://getcomposer.org/installer //下载一个脚本文件 php installer //php执行下这个php脚本(虚拟机我没装环境.以下截图有操作流程) ...

  7. vs2013中集成Git

    一:为什么不用2013中自带的? 我的2013自带的没法用,连最基本的克隆都用不了,网上看着下  好像说都不能用:不知道各位的如何. 二:如何自己讲Git集成到vs2013中? 需要的工具:     ...

  8. CentOS7 分布式安装 Hadoop 2.8

    1. 基本环境 1.1 操作系统 操作系统:CentOS7.3 1.2 三台虚拟机 172.20.20.100 master 172.20.20.101 slave1 172.20.20.102 sl ...

  9. #WEB安全基础 : HTML/CSS | 0x9美丽的饮料店

    我带着你,你带着钱,咱们去喝点饮料吧. 老板久仰你的大名,请你帮忙设计一个网站宣传他的饮料店 你要制定一个完美的方案还需要多学点东西 我先帮你设计一下 这是存放网站的文件夹 这是根目录   这是abo ...

  10. 缓存ABC

    缓存ABC Intro 缓存是一种比较常见的用来将提高系统性能的方式.从线程缓存.进程缓存.到内存缓存再到分布式缓存再到CDN,都是属于缓存的范畴. 缓存的本质是空间换时间以提高读的效率,牺牲一些内存 ...