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官方用户指南

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值