Docker入门

获取Ubuntu的Docker CE

Docker官方教程

卸载旧版本

如果安装过旧版本docker, docker.io或docker-engine, 请先卸载它们:

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

准备工作

首次安装Docker CE之前,需要设置Docker存储库。之后,您可以从存储库安装和更新Docker。

1. 更新 apt 包索引

$ sudo apt-get update

2. 安装相关工具包(https, CA)

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

3. 添加 Docker 的官方 GPG 密钥

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

验证密钥:

$ sudo apt-key fingerprint 0ebfcd88

4. 添加 Docker 存储库

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

安装 Docker CE

1. 更新 apt 包索引

$ sudo apt-get update

2. 安装最新版本的 Docker CE 和 containerd

$ sudo apt-get install docker-ce docker-ce-cli containerd.io
(下载安装时间网速决定)

3. 运行 hello-world 映像验证是否正确安装了 Docker CE

$ sudo docker run hello-world

#  显示以下内容
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 CE

卸载 Docker CE 软件包:

$ sudo apt-get purge docker-ce

主机上的图像,容器,卷或自定义配置文件不会自动删除。
要删除所有图像,容器和卷您必须手动删除任何已编辑的配置文件:

$ sudo rm -rf /var/lib/docker

下一步

Docker官方用户指南

你可能感兴趣的:(docker,Docker)