ubuntu 安装 docker 步骤详解

首先检查或者卸载残留docker程序

sudo apt-get remove docker docker-engine docker.io containerd runc

更新软件仓库

sudo apt-get update

安装所需依赖环境

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

安装密钥

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

验证密钥是否正确

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) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

添加稳定镜像源

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

安装docker

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

测试安装是否成功

service docker status

启动docker服务

sudo service docker start

运行hello-world 镜像

docker run hello-world