前言:

docker官网有很详细的安装教程,建议按照官网的步骤进行安装。

Install Docker on Ubuntu:https://docs.docker.com/engine/installation/linux/ubuntulinux/

docker需要3.10或者更高版本的内核支持,通过uname -r查看内核版本。


步一:更新apt源

$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates


步二:添加新的GPG密钥

$ sudo apt-key adv \
               --keyserver hkp://ha.pool.sks-keyservers.net:80 \
               --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

步三:通过lsb_release -a命令查看系统的版本,Ubuntu14.04

Trusty 14.04 (LTS) 	deb https://apt.dockerproject.org/repo ubuntu-trusty main

步四:设置源

$ echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list

步五:更新APT

$ sudo apt-get update

步六:确认APT已经更新,正常会输出结果

$ apt-cache policy docker-engine

  docker-engine:
    Installed: 1.12.2-0~trusty
    Candidate: 1.12.2-0~trusty
    Version table:
   *** 1.12.2-0~trusty 0
          500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
          100 /var/lib/dpkg/status
       1.12.1-0~trusty 0
          500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
       1.12.0-0~trusty 0
          500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages


步七:再次更新源

$ sudo apt-get update


步八:安装增强包

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


步九:再次更新源

$ sudo apt-get update


步十:安装Docker

$ sudo apt-get install docker-engine

步十一:启动Docker守护进程

$ sudo service docker start

步十二:确认安装成功,这个命令会下载一个测试镜像。

$ sudo docker run hello-world

看到这个界面意味着成功了:

$ docker run hello-world
 Unable to find image 'hello-world:latest' locally
 latest: Pulling from library/hello-world
 535020c3e8ad: Pull complete
 af340544ed62: Pull complete
 Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
 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 Engine CLI client contacted the Docker Engine daemon.
 2. The Docker Engine daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker Engine daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker Engine daemon streamed that output to the Docker Engine CLI 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 Hub account:
 https://hub.docker.com

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


步十三:查看所有的容器

$ docker ps -a

原文出自:http://blog.csdn.net/daiyudong2020/article/details/53353064


End;


Logo

更多推荐