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 Edition Command
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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM