ubuntu16.04安装docker

docker有企业版(EE版)和社区版(CE版),企业版是要收费的,所以选择社区版进行安装。

系统要求:

不是所有的ubuntu版本都能安装cocker,因为docker是使用go语言编写的,所以早期的ubuntu版本并不能支持,能安装的版本包括

  • Cosmic 18.10
  • Bionic 18.04 (LTS)
  • Xenial 16.04 (LTS)

1:更新仓库

 sudo apt-get update

2:安装apt使用https所需的包

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

 3:添加GPG密钥

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

4:校验密钥

sudo apt-key fingerprint 0EBFCD88

 如果输出

pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) 
sub   rsa4096 2017-02-22 [S]

 则表示校验成功

5:安装仓库,稳定仓库:

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

特别说明,不同处理器的安装是不一样的,上面命令是在arm64处理器上的安装命令,下面列举不同处理器的安装命令:

#x86_64/amd
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
#armhf
sudo add-apt-repository \
   "deb [arch=armhf] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
#ppc64le (IBM Power)
sudo add-apt-repository \
   "deb [arch=ppc64el] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable

 

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

:6:更新一下源:

sudo apt-get update

:7:开始安装docker

 sudo apt-get install docker-ce docker-ce-cli containerd.io

如果需要安装指定的版本号,可以使用

apt-cache madison docker-ce

 列出查看所有的docker版本,安装指定版本命令:

$ sudo apt-get install docker-ce= docker-ce-cli= containerd.io

到此,安装完毕,查看helloworld

sudo docker run hello-world

首次运行会提示没有镜像,docker会自动到远程仓库里下载hello-world镜像

 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.

 看到上面输出,表示安装成功,docker相关命令可以使用docker --help查看

你可能感兴趣的:(ubuntu16.04安装docker)