前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >最简单的教程:在Ubuntu操作系统里安装Docker

最简单的教程:在Ubuntu操作系统里安装Docker

原创
作者头像
Jerry Wang
发布2018-09-18 12:24:55
7430
发布2018-09-18 12:24:55
举报

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。

今天这篇文章咱们就来将Docker安装到Ubuntu上。

1. 由于Ubuntu里apt官方库里的docker版本可能比较低,因此先用下面的命令行卸载旧版本(如果有的话)

sudo apt-get remove docker docker-engine docker-ce docker.io

2. 更新apt包索引:

sudo apt-get update

3. 执行下列命令行,使apt可以通过HTTPS协议去使用存储库:

sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common

4. 添加Docker官方提供的GPG密钥:

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

什么是GPG密钥呢?大家可以从阮一峰老师的博客:GPG入门教程里获得答案:

1991年,程序员Phil Zimmermann为了避开政府监视,开发了加密软件PGP。这个软件非常好用,迅速流传开来,成了许多程序员的必备工具。但是,它是商业软件,不能自由使用。所以,自由软件基金会决定,开发一个PGP的替代品,取名为GnuPG。这就是GPG的由来。

上面的文字出自阮一峰老师的博客链接:http://www.ruanyifeng.com/blog/2013/07/gpg.html

5. 设置stable存储库:

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

最后再次更新apt包索引:

6. 安装最新版本的docker-ce:

sudo apt-get install -y docker-ce

安装完毕后,可以看到Docker服务已经从/lib/systemd/system/docker.service启动了,dockerd进程id为4921:

命令行ps -aux查看进程id为4921的进程路径:/usr/bin/dockerd -H fd://

使用命令sudo docker version可以查看安装docker的版本:

使用命令sudo docker run hello-world,能观察到从远程下载这个测试用的容器:Pulling from library/hello-world:

然后看到打印消息:Hello from Docker! 说明Docker安装成功。

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/engine/userguide/

要获取更多Jerry的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码:

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档