Kubernetes(一):Ubuntu上安装Docker

前言

参考Docker官方文档在阿里云ECS实例上安装Docker。
官方文档:https://docs.docker.com/install/linux/docker-ce/ubuntu/

安装要求

Docker CE要求的Ubuntu版本:

  • Disco 19.04
  • Cosmic 18.10
  • Bionic 18.04 (LTS)
  • Xenial 16.04 (LTS)
# 查看系统版本
$ cat /proc/version
Linux version 4.4.0-142-generic (buildd@lgw01-amd64-033) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) ) #168-Ubuntu SMP Wed Jan 16 21:00:45 UTC 2019
# 查看发行版名称
$ lsb_release -cs
xenial

卸载旧版本(略)

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

准备工作

# 更新源
$ sudo apt-get update
# 安装必要的工具,如HTTPS工具、GPG工具等
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
# 添加docker的gpg秘钥到apt-key密钥中,用于确认所下载的软件包的合法性
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# 添加docker源
# 可以使用aliyun的内网镜像代替:http://mirrors.cloud.aliyuncs.com/docker-ce/linux/ubuntu
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

安装

# 更新源
$ sudo apt-get update
# 安装
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

验证

$ docker version
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:9572f7cdcee8591948c2963463447a53466950b3fc15a247fcad1917ca215a2f
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 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.

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 ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

至此docker已正确安装

你可能感兴趣的:(Kubernetes(一):Ubuntu上安装Docker)