安装docker

Docker安装CE(Community Edition)

参考官方文档

环境:Ubuntu 14.04 (LTS)

Ubuntu Trusty 14.04 建议安装 extra 包。只有安装 linux-image-extra-* 包, Docker 才能使用 aufs 存储驱动。

$ sudo apt-get update

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

使用仓库方式安装

(一)、安装仓库

1、更新apt包索引

root@ubuntu:~#  sudo apt-get update

2、安装包以允许**apt**在HTTPS上使用仓库
$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

3、添加Docker官方的GPG秘钥。根据9DC8 5822 9FC7 DD38 854 A E2D8 8D8803C 0EBF CD88最后8位字符进行验证秘钥
root@ubuntu:~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK

root@ubuntu:~# 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

4、用以下命令来设置 stable 的仓库。
root@ubuntu:~# sudo add-apt-repository \
>    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
>    $(lsb_release -cs) \
>    stable"

【备注】:lsb_release -cs子命令返回Ubuntu发行版的名字:

root@ubuntu:~# lsb_release -cs
trusty


(二)、安装DOCKER CE

1、更新apt包索引

root@ubuntu:~#  sudo apt-get update

2、安装最新版本的Docker CE(或者安装指定版本,见步骤3)
root@ubuntu:~# sudo apt-get install docker-ce

如果启用了多个DOCK仓库,则在apt-ge install t或apt-get update 命令中不指定版本的安装或更新总是安装最高可能的版本;


3、安装Docker CE指定版本

a. 列出系统可用的Docker CE版本;

root@ubuntu:~# apt-cache madison docker-ce
 docker-ce | 18.03.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.12.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.12.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.09.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.06.2~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.06.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.03.2~ce-0~ubuntu-trusty | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.03.1~ce-0~ubuntu-trusty | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.03.0~ce-0~ubuntu-trusty | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages

b. 安装指定版本 docker-ce=,eg.docker-ce=18.03.0~ce-0~ubuntu
$ sudo apt-get install docker-ce=17.12.1~ce-0~ubuntu

验证hello-world结果:
root@ubuntu:~# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete 
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for hello-world:latest

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.
    (amd64)
 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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

root@ubuntu:~# 

posted @ 2018-07-04 13:34  1024狮子  阅读(159)  评论(0编辑  收藏  举报