docker安装

1. 安装docker repository

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

    $ sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        software-properties-common
    
  2. Add Docker’s official GPG key:

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

    Verify that the key fingerprint is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

    $ 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
    
  3. Use the following command to set up the stable repository.

    Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such as xenial.

    Sometimes, in a distribution like Linux Mint, you might have to change $(lsb_release -cs) to your parent Ubuntu distribution. For example: If you are using Linux Mint Rafaela, you could use trusty.

    To add the edge repository, add edge after stable on the last line of the command. For information about stable and edge builds, see Docker variants.

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

2.  Update the apt package index.

$ sudo apt-get update

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

Use this command to install the latest version of Docker:

Docker EditionCommand
Docker CE sudo apt-get install docker-ce
Docker EE sudo apt-get install docker-ee

4. 生产环境安装docker要指定版本安装,不要安装最新版本。首先运行下行的命令,找到和ubuntu当前版本对应的docker版本。

 apt-cache madison docker-ce

第二列是版本号,第三列是repository 当前是来自stablerepository

 

5. Hello world 验证:

sudo docker run hello-world

会下载hello-world image, 在docker中运行打印结果 

 

6. 加速docker hub访问。由于用到的image在阿里云镜像里面找不到,只能使用官方的,所以需要 docker -> polipo -> sock5来加速.

docker如何配置http proxy参见文档:https://docs.docker.com/engine/admin/systemd/ 

 

7. 去除sudo等。https://docs.docker.com/engine/installation/linux/linux-postinstall/#manage-docker-as-a-non-root-user

 

posted @ 2017-03-06 13:32  怎么也得过啊  阅读(2707)  评论(0编辑  收藏  举报