zoukankan      html  css  js  c++  java
  • 最简单的教程:在Ubuntu操作系统里安装Docker

    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的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码:

  • 相关阅读:
    Tree的两种存储形式
    滚轮缩放效果
    从hello world 说程序运行机制
    词法分析器的实现
    MSDN中回调函数的讲解及其C#例子:用委托实现回调函数
    在后台new出页面(组件)
    HTML中多种空格转义字符
    ios 博客集合
    IOS学习
    Apple Swift编程语言入门教程
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/9820844.html
Copyright © 2011-2022 走看看