关闭 x
IT技术网
    技 采 号
    ITJS.cn - 技术改变世界
    • 实用工具
    • 菜鸟教程
    IT采购网 中国存储网 科技号 CIO智库

    IT技术网

    IT采购网
    • 首页
    • 行业资讯
    • 系统运维
      • 操作系统
        • Windows
        • Linux
        • Mac OS
      • 数据库
        • MySQL
        • Oracle
        • SQL Server
      • 网站建设
    • 人工智能
    • 半导体芯片
    • 笔记本电脑
    • 智能手机
    • 智能汽车
    • 编程语言
    IT技术网 - ITJS.CN
    首页 » HTML5 »在 Mac OS X 上安装红帽容器开发工具包

    在 Mac OS X 上安装红帽容器开发工具包

    2015-05-24 00:00:00 出处:linux.cn
    分享

    容器技术很棒,它将会改变我们开发好传递软件的方式。当然也有一个批评此技术的人认为它并不安全和足够安全的在产品环境运行。

    随着 Red Hat Enterprise Linux 7.1 和 Red Hat Atomic 的登陆,企业和组织机构可以不用牺牲安全性和性能,也能拥抱这一新技术趋势。

    什么 Red Hat CDK

    CDK 是 Container Development Kit(容器开发包)的缩写,它能让开发者在他们的桌面系统上使用 Red Hat Atomic,不管他们所使用的是 Microsoft Windows ,Mac OS X 或者其他 Linux 的发行版。同boot2docker类似,CDK利用虚拟机来启动一个小的主机,它能运行基于 Red Hat Enterprise Linux 的容器。

    前置条件

    Red Hat 订阅 – 要安装 Red Hat CDK 你就得拥有一个激活了的 Red Hat Enterprise Linux 订阅, 假如没有,可以在 这里 进行申请和查看。 虚拟环境 – virtualBox (Mac/Windows) 或者 virt-manager (Linux) Vagrant – 用来创建和管理虚拟环境。

    从 Red Hat 消费者门户 下载下面这些东西。

    Red Hat 容器工具(Container Tools) 面向 VirtualBox 的 Red Hat Atomic Vagrant 盒子 或者 面向libvirt 的 Red Hat Atomic Vagrant 盒子。

    安装 Red Hat 容器开发包

    注意:在这之前你需要安装好虚拟化环境以及 Vagrant

    解压你下载的 cdk.zip 文件到主目录. 这样会创建 ~/cdk (/Users/username/cdk)

    $ unzip -d $HOME ~/Downloads/cdk-1.0-0.zip

    安装使用 Red Hat Vagrant 所需要的 Vagrant 插件. 第一个插件会花几分钟时间,Vagrant 可能会需要安装一些额外的gem文件。

    $ cd ~/cdk/plugins
    $ vagrant plugin install vagrant-registration-0.0.8.gem
    $ vagrant plugin install vagrant-atomic-0.0.3.gem

    验证插件是否已经安装好了:

    $ vagrant plugin list
    vagrant-atomic (0.0.3)
      - Version Constraint: 0.0.3
    vagrant-registration (0.0.8)
     - Version Constraint: 0.0.8

    将 RHEL Atomic 盒子添加到 Vagrant:

    $ vagrant box add --name rhel-atomic-7 ~/Downloads/rhel-atomic-virtualbox-7.1-0.x86_64.box

    启动 Atomic 主机

    为 docker 文件创建一个工作目录

    $ mkdir ~/containers && cd ~/containers

    为容器创建一个工作目录,并初始化 vagrant

    $ mkdir containers && cd containers
    $ vagrant init -m
    A `Vagrantfile` has been placed in this directory. You are now
    ready to `vagrant up` your first virtual environment! Please read
    the comments in the Vagrantfile as well as documentation on
    `vagrantup.com` for more information on using Vagrant.

    这一步会创建一个简单的 Vagrant 文件。打开它并像下面这样修改配置:

    Vagrant.configure(2) do |config|
      config.vm.box = "rhel-atomic-7"
      config.vm.hostname = "rhel-atomic-7-docker-host"
    
      config.vm.provider "virtualbox" do |vb|
        vb.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
        vb.memory = 4096
      end
    
      config.vm.provision "shell", inline: <<-SHELL
        sudo systemctl stop docker > /dev/null 2>&1
        sudo groupadd docker > /dev/null 2>&1
        sudo usermod -a -G docker vagrant
        sudo systemctl enable docker && sudo systemctl start docker
        sudo chown root:docker /var/run/docker.sock
        sudo systemctl enable docker && sudo systemctl start docker
      SHELL
    end

    我们现在已经做好了启动容器的准备。在机器的创建过程中,你将会看到是否想要注册系统的提示。回答 “Y” 就会要你输入RHN (Red Hat Network) 账户的用户名和密码.

    $ vagrant up
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Importing base box 'rhel-atomic-7'...
    ==> default: Matching MAC address for NAT networking...
    ==> default: Setting the name of the VM: containers_default_1432213616739_95846
    ==> default: Clearing any previously set network interfaces...
    ==> default: Preparing network interfaces based on configuration...
        default: Adapter 1: nat
    ==> default: Forwarding ports...
        default: 22 => 2222 (adapter 1)
    ==> default: Running 'pre-boot' VM customizations...
    ==> default: Booting VM...
    ==> default: Waiting for machine to boot. This may take a few minutes...
        default: SSH address: 127.0.0.1:2222
        default: SSH username: vagrant
        default: SSH auth method: private key
        default: Warning: Connection timeout. Retrying...
        default: 
        default: Vagrant insecure key detected. Vagrant will automatically replace
        default: this with a newly generated keypair for better security.
        default: 
        default: Inserting generated public key within guest...
        default: Removing insecure key from the guest if its present...
        default: Key inserted! Disconnecting and reconnecting using new SSH key...
    ==> default: Machine booted and ready!
    ==> default: Checking for guest additions in VM...
        default: No guest additions were detected on the base box for this VM! Guest
        default: additions are required for forwarded ports, shared folders, host only
        default: networking, and more. If SSH fails on this machine, please install
        default: the guest additions and repackage the box to continue.
        default: 
        default: This is not an error message; everything may continue to work properly,
        default: in which case you may ignore this message.
    ==> default: Setting hostname...
    ==> default: Registering box with vagrant-registration...
        default: Would you like to register the system now (default: yes)  [y|n] y
        default: Subscriber username: <your-rhn-username>
        default: Subscriber password: <password>==> default: Rsyncing folder: /Users/tqvarnst/containers/ => /home/vagrant/sync
    ==> default: Running provisioner: shell...
        default: Running: inline script

    测试你的安装

    $ vagrant ssh
    [vagrant@rhel-atomic-7-docker-host ~]$ docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    [vagrant@rhel-atomic-7-docker-host ~]$ docker run -it rhel7.1 bash
    Unable to find image 'rhel7.1:latest' locally
    Pulling repository registry.access.redhat.com/rhel7.1
    10acc31def5d: Download complete 
    Status: Downloaded newer image for registry.access.redhat.com/rhel7.1:latest
    [root@ead3774c2b84 /]# cat /etc/redhat-release 
    Red Hat Enterprise Linux Server release 7.1 (Maipo)
    [root@ead3774c2b84 /]#

    按下 CTRL-P + CTRL-Q 可以离开你的容器

    [vagrant@rhel-atomic-7-docker-host ~]$ docker ps
    CONTAINER ID        IMAGE                                      COMMAND             CREATED              STATUS              PORTS               NAMES
    ead3774c2b84        registry.access.redhat.com/rhel7.1:7.1-4   "bash"              About a minute ago   Up About a minute                       focused_rosalind

    如下命令可以停掉或者删除容器

    [vagrant@rhel-atomic-7-docker-host ~]$ docker stop $(docker ps -q)
    ead3774c2b84
    [vagrant@rhel-atomic-7-docker-host ~]$ docker rm $(docker ps -aq)
    ead3774c2b84

    总结

    通过这个指南,你就可以有一个可以来使用基于 Red Hat Enterprise Linux 7.1 的容器的工作环境,不管你使用的是 Mac OS X ,Microsoft Windows 还是其它的Linux发行版。

    鸣谢

    特别要感谢 Pete Muir 在Vagrant设置上给我带来的支持和帮助。

    上一篇返回首页 下一篇

    声明: 此文观点不代表本站立场;转载务必保留本文链接;版权疑问请联系我们。

    别人在看

    电脑屏幕不小心竖起来了?别慌,快捷键搞定

    Destoon 模板存放规则及语法参考

    Destoon系统常量与变量

    Destoon系统目录文件结构说明

    Destoon 系统安装指南

    Destoon会员公司主页模板风格添加方法

    Destoon 二次开发入门

    Microsoft 将于 2026 年 10 月终止对 Windows 11 SE 的支持

    Windows 11 存储感知如何设置?了解Windows 11 存储感知开启的好处

    Windows 11 24H2 更新灾难:系统升级了,SSD固态盘不见了...

    IT头条

    Synology 更新 ActiveProtect Manager 1.1 以增强企业网络弹性和合规性

    00:43

    新的 Rubrik Agent Cloud 加速了可信的企业 AI 代理部署

    00:34

    宇树科技 G1人形机器人,拉动一辆重达1.4吨的汽车

    00:21

    Cloudera 调查发现,96% 的企业已将 AI 集成到核心业务流程中,这表明 AI 已从竞争优势转变为强制性实践

    02:05

    投资者反对马斯克 1 万亿美元薪酬方案,要求重组特斯拉董事会

    01:18

    技术热点

    大型网站的 HTTPS 实践(三):基于协议和配置的优化

    ubuntu下右键菜单添加新建word、excel文档等快捷方式

    Sublime Text 简明教程

    用户定义SQL Server函数的描述

    怎么在windows 7开始菜单中添加下载选项?

    SQL Server 2016将有哪些功能改进?

      友情链接:
    • IT采购网
    • 科技号
    • 中国存储网
    • 存储网
    • 半导体联盟
    • 医疗软件网
    • 软件中国
    • ITbrand
    • 采购中国
    • CIO智库
    • 考研题库
    • 法务网
    • AI工具网
    • 电子芯片网
    • 安全库
    • 隐私保护
    • 版权申明
    • 联系我们
    IT技术网 版权所有 © 2020-2025,京ICP备14047533号-20,Power by OK设计网

    在上方输入关键词后,回车键 开始搜索。Esc键 取消该搜索窗口。