阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

在Ubuntu 16.04上安装Rancher

147次阅读
没有评论

共计 3046 个字符,预计需要花费 8 分钟才能阅读完成。

介绍

Rancher 是运行容器和构建私有容器服务的开源平台。Rancher 基于 Docker,因此您可以在专用的 box,KVM 机器上甚至 LXC 容器上运行它。Rancher 提供了一个庞大的应用程序库,只需点击几下即可安装,并且还支持来自 Dockerhub 的 Docker 镜像。

要求

  • 一个 Vultr 实例 Ubuntu 16.04 x64。
  • 至少 1GB 内存。
  • 受支持的 Docker 版本。

安装 Docker

如上所述,Docker 需要运行 Rancher,所以我们会先安装它。

首先,如有必要,删除所有旧的 Docker 文件。

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

注意:您可能会收到没有安装 Docker 文件的报告。这是可以忽略的。

更新软件包列表。

sudo apt-get update

允许 apt 通过 HTTPS 使用存储库。

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

添加官方的 GPG 密钥。

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

通过搜索密钥指纹的最后 8 位数字来验证您是否拥有密钥。

sudo apt-key fingerprint 0EBFCD88

输出将类似于以下文本。

pub  4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <docker@docker.com>
sub  4096R/F273FCD8 2017-02-22

添加一个稳定的 repo。

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

再次更新软件包列表。

sudo apt-get update

检查 Docker CE 的可用版本。

apt-cache madison docker-ce

您将看到类似于以下块的输出。

docker-ce | 17.09.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.2~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.2~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

在以下命令中追加 = 后的最新稳定版本的版本字符串(第二列)以安装最新版本的 Docker CE。

sudo apt-get install docker-ce=17.09.1~ce-0~ubuntu 

注意:您可以安装最新版本的 Docker CE,而无需将版本附加到 sudo apt-get install docker-ce 命令的末尾,但在生产环境中,我建议您安装特定版本而不是最新版本。

确认 Docker 安装正确。

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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

安装 Rancher

现在我们准备安装 Rancher。

sudo docker run -d –restart=unless-stopped -p 8080:8080 rancher/server:stable

等待几分钟让 Rancher UI 启动。然后,打开您最喜欢的浏览器并转到服务器上的端口 8080。

http://192.0.2.0:8080

请务必将 192.0.2.0 替换为您的实际服务器的 IP 地址。

Rancher 默认情况下不配置访问控制,因此立即设置它非常重要,否则拥有您的 IP 的任何人都可以访问 UI 和 API。

将鼠标悬停在管理员标签上,然后点击访问控制。

按照 Rancher UI 中的说明设置您喜欢的任何形式的访问控制。

结论

现在已经安装了所有东西,您可以开始配置 Rancher。有关配置和使用 Rancher 的更多深入信息,请访问其官方文档。

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计3046字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中